Grep within certain file types

Want to search some text only in the code files and to ignore log files. Specially a pain when you search recursively. Here’s a simple solution

grep --include=*.php --include=*.module -r text_to_search *

Another alternative when the file type options are large in number

grep --include=*.{html,php,module,html} -r text_to_search *
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s