Search Files In Linux For Text String
This is easily accomplished via the grep command.
1 | grep “find text” /home/greg/*.txt |
The same search but will go recursively down the structure.
1 | grep -r “find text” /home/greg/*.txt |
The following is recursion and it will also print the file name that the text was found in.
1 | grep -H -r “find text” /home/greg/*.txt |
One of my favorite’s:
grep -R -B3 -A3 “find text” /var/log/
Recursively returns 3 lines before and 3 lines after with a match. 😀