In a directory I have a file that contains the word string.When I do: grep string . no results are returned.But when I do grep -r string . the file is returned.Why is -r option needed? It does not look inside internal subdirectories.
Is -r mandatory for grep?
grep
No it is not mandatory. grep string . means look for string in a file called .. If you want to run grep on all files in the current directory, use grep string * and if you want to look in all files in all subdirectories recursively, do grep -r string.