When I want to grep all the html files in some directory, I do the following
grep --include=\"*.html\" pattern -R /some/path
which works well. T
Try this. -r will do a recursive search. -s will suppress file not found errors. -n will show you the line number of the file where the pattern is found.
grep "pattern" <path> -r -s -n --include=*.{c,cpp,C,h}
Use grep
with find
command
find /some/path -name '*.html' -o -name '*.htm' -o -name '*.php' -type f
-exec grep PATTERN {} \+
You can use -regex
and -regextype
options too.
It works for the same purpose, but without --include
option. It works on grep 2.5.1 as well.
grep -v -E ".*\.(html|htm|php)"
You can use multiple --include
flags. This works for me:
grep -r --include=*.html --include=*.php --include=*.htm "pattern" /some/path/
However, you can do as Deruijter
suggested. This works for me:
grep -r --include=*.{html,php,htm} "pattern" /some/path/
Don't forget that you can use find
and xargs
for this sort of thing to:
find /some/path/ -name "*.htm*" -or -name "*.php" | xargs grep "pattern"
HTH
Try removing the double quotes
grep --include=*.{html,php,htm} pattern -R /some/path
is this not working?
grep pattern /some/path/*.{html,php,htm}