find usage with -L
The general rule is that if a command operates on links (i.e. directory entries, which are pointers to inodes) then the command treats symlinks as themselves rather than as the object the link points to. Otherwise the command operates on what the symlink points to. Thus cp
follows symlinks by default and copies the contents of the file pointed to by the link. But when you ask cp
to deal with directory entries by specifying -R
, it stops following symlinks. mv
always works with directory entries, and so it never follows symlinks.
The find
command's normal activity is to operate on directory entries, so symlinks are not followed by default. Adding -L
causes find
to follow symlinks for all properties except the one that cannot be ignored when doing directory search, the name. One of purposes of find -name
is to provide input for commands like mv
and rm
, which operate on directory entries. There would be unpleasant and surprising results if find -L dir -name
could produce names that pointed outside the directory tree rooted at dir
.
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.