Shell Tricks

To search for all files that contain a certain string use find with the -exec flag. For example:

find . -name "*.haystack" -type f -exec grep -l needle "{}" ";"

grep -l flag tells grep to output only the file name if there is a match.
"{}" is replaced iteratively by the file names found.
";" terminates the command.

One thought on “Shell Tricks

Leave a Reply

Your email address will not be published. Required fields are marked *