//View Tip #147
» dos2unix all files in a directory
» another solution to #67
» Grep for word in directory
» Change prompt color dynamically
Similar Tips
» Kill matching processes» dos2unix all files in a directory
» another solution to #67
» Grep for word in directory
» Change prompt color dynamically
Latest tips by RSS
Click here to subscribe
Follow Shell-Fu on Twitter
Click here to follow
Follow Shell-Fu on identi.ca
Click here to follow
Find all files with given name (you can use Bash expansion if you'd like), and Grep for a phrase:
To display the filename that contained a match, use -print:
Or, use Grep options to print the filename and line number for each match:
The string `{}` is replaced by the current filename being processed everywhere it occurs in the arguments to the command. See the `find` man page for more information.
find . -name-exec grep "phrase" {} \;
To display the filename that contained a match, use -print:
find . -name-exec grep "phrase" {} \; -print
Or, use Grep options to print the filename and line number for each match:
find . -name-exec grep -Hn "phrase" {} \;
The string `{}` is replaced by the current filename being processed everywhere it occurs in the arguments to the command. See the `find` man page for more information.
Comments
Add your comment
Comments are currently disabled


grep -R "phrase" ./mydir/*.txt
it's this way only