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.
egrep is equivalent to grep -E command and it allows the use of extended regex. fgrep is equivalent to grep -F command and it uses a fixed string for search and hence it performs a faster search.
The main difference between grep and egrep is that grep is a command that allows searching content according to the given regular expression and displaying the matching lines while egrep is a variant of grep that helps to search content by applying extended regular expressions to display the machining lines.
The sed command is a stream editor that works on streams of characters. It's a more powerful tool than grep as it offers more options for text processing purposes, including the substitute command, which sed is most commonly known for.
Grep is used for finding text patterns in a file and is the simplest of the three. Sed can find and modify data, however, its syntax is a bit more complex than grep. AWK is a full-fledged programming language that can process text and perform comparison and arithmetic operations on the extracted text.
"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, if grep -r
encounters a symbolic link while traversing a directory it does not follow it (in contrast to grep -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):
$ ls -la
total 0
drwxr-xr-x 2 aw aw 47 Mar 31 16:05 .
drwxr-xr-x 3 aw aw 27 Mar 31 16:04 ..
-rw-r--r-- 1 aw aw 0 Mar 31 16:05 bar
-rw-r--r-- 1 aw aw 0 Mar 31 16:05 baz
lrwxrwxrwx 1 aw aw 2 Mar 31 16:04 foo -> ..
-rw-r--r-- 1 aw aw 0 Mar 31 16:05 quux
$
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With