bash: Find specifying certain file extensions
I had terrible trouble finding a way to do this in bash, doesn’t seem to be possible using -name or -iname :-
find /var/www/html/ -regex “.*\(php\|js\|inc\)” -exec grep -i ‘tbl_title’ {} +
find /var/www/html/ -regex “.*\(php\|js\|inc\)” -exec grep -i ‘tbl_title’ {} \;
NB: the \; and + endings are different the + ending usefully displays the matching file name
Of course if you have a recent bash you will likely prefer:-
grep -ilR –include=*.{php,inc,js} ‘fn_main’ c:/inetpub/wwwroot
or
grep -iR –include=*.{php,inc,js} ‘fn_main’ c:/inetpub/wwwroot
Categories: shell tips