Laxmikant Gurnalkar Laxmikant Gurnalkar - 1 year ago 116
Linux Question

grep recursively for a specific file type in Linux terminal

Can we search a term (eg. "onblur") recursively in some folders only in specific files (html files)?

grep -Rin "onblur" *.html

This returns nothing. But,

grep -Rin "onblur" .

search result from all available files, like in text(".txt"), .mako, .jinja etc.

Answer Source

Consider checking this answer and that one.

Also this might help you: grep certain file types recursively |

The command is:

grep -r --include="*.[ch]" pattern .

And in your case it is:

grep -r --include="*.html" "onblur" .
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download