Find – Usage with -L Option for Symlinks

findsymlink

I have

link -> file

I do

find -L . -name 'link'

And get

./link

Why is that?

man find says:

-L : Follow symbolic links. When find examines or prints information about files, the information used shall be
taken from the properties of the file to which the link points, not from the link itself (unless it is a bro‐
ken symbolic link or find is unable to examine the file to which the link points).

Best Answer

With -L, it examines the properties of the file - contents or metadata, not those of the link. E.g. if you use -atime, it will check the atime of the file, not the link:

$ find testdir/ -name link -newer testdir/ref
testdir/link
$ find -L testdir/ -name link -newer testdir/ref
$

testdir/link was created after testdir/ref, but the file it points at was not.

Related Question