Grepping through subdirectories

Posted on 2007-04-12

This is how to grep recursively through subdirectories but only for files that match a specific pattern:
grep -l -r --include=*.htm regex *
The equivalent command with find is:
find . -name '*.htm' -exec grep -l regex \{\} \;
The option after grep is the lowercase letter L, not the number 1). Remove the -l to see the actual matches instead of the file names.

Tags: find grep