Useful greps (briefly)

8 07 2010

To look for a particular string in the current directory:

$grep <search-text> *

Using the ‘-l’ option the command only lists the filenames that have at least one instance of the string.

$grep -l <search-text> *

To look for a particular string in all the files in the current directory and sub-directories:

$grep -r <search-text>

Of course the ‘-l’ and ‘-r’ can be combined to give us the filenames that include at least one instance of the string in the current directory or sub-directories:

$grep -lr <search-text>
Advertisements

Actions

Information

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




%d bloggers like this: