Finding File(s) With Specified Text on Linux

Posted on Thursday, February 4, 2010

0


grep command form (syntax)

grep “text string to search” directory-path

Current Directory –>

$ grep "offset" ./*.txt

Directories Recursively –>

Search for a text string all files under each directory, recursively with -r option:
$ grep -r "offset" /home/vhazrati

Only Filenames–>

Pass -H option to print the filename for each match.
$ grep -H -r “offset” /home/vhazrati

About these ads
Posted in: linux