Quick note to remember this syntax as every few months I find a need to do a grep within a number of files:
find -name "pattern" -exec grep "pattern" {} ;
Grep options:
-H print filename in results
-n print line number where match was found
-l limit match to first found match in file (useful if you want to find files containing a match but don’t care how many matches are in each file)
Pipe to wc -l to count file occurrences, eg:
find -name "pattern" -exec grep -l "pattern" {} ; | wc -l
Use egrep if you need to use regex in the pattern.