grep -rn word / directory
Now more. What is grep, you most likely already know. This utility is used as an output filter text information in the console.
-r – grep will pass directories recursively
-n – grep displays the line number in results
word – indicated by the word, which are looking for
/ Directory – indicates the directory. For example / home / $ user / docs
A few examples.
inky @ support68: ~ $ grep -rn word / home / inky / docs /
/home/inky/docs/doc1.txt:11:some word here
In the 11th line of the file contains the word /home/inky/docs/doc1.txt word (after 11: displays the string itself)
inky @ support68: ~ $ grep -rn «few words» / home / inky / docs /
/home/inky/docs/doc1.txt:19:few words here
In line 19y file phrase found few words.
And the example of egrep:
inky @ support68: ~ $ egrep -rn ‘(word1 | word2 | word3)’ / home / inky / docs /
We were looking for word1 or word2 or word3. In the 20th there was a line word1, in 21y – word2, in the 22nd – word3.
I use it mainly to search for iframe hosting servers. Sometimes it is also useful to find anything in the catalogs with a large number of configuration files.