How do I recursively grep through all sub-directories and find files containing given text / string or words?
You can use the -r option to recursively grep through all sub-directories and find text. The syntax is as follows:
grep -r "text" /path/to/dir |
In this example, search for an IP 192.168.1.254 in through all /etc/ and all its sub-directories:
grep -r "192.168.1.254" /etc/ |
Search in any case:
grep -ri "letters" /home/vivek/data |
Use the -l switch to display only the names of files in which the text occurs:
grep -lri "foo" /data |