In the man page:
-r
Read all files under each directory, recursively, following symbolic links only if they are on the command line.
what exactly does "being on the command line" means?
Thanks.
In the man page:
-r
Read all files under each directory, recursively, following symbolic links only if they are on the command line.
what exactly does "being on the command line" means?
Thanks.
"Being on the command line" refers to the arguments passed to grep. If you give a symbolic link as an argument to
grep -r
it follows it. However, ifgrep -r
encounters a symbolic link while traversing a directory it does not follow it (in contrast togrep -R
which does).Imagine you have a directory with a bunch of files in it, including one containing a symbolic link to
..
(the parent directory):Then,
grep -r foobar .
will only grep the files inside this directory,grep -r foobar foo
will grep the files in the parent directory (..
) (following the symlink given as an argument),grep -R foobar .
will also grep the files in the parent directory (following the symlink not given as an argument but found while traversing the current directory).If you check also
man grep
:See an example:
We create in
/test
a file with the contentAnd then I create a symlink:
So that it looks like:
And now we
grep
: