Posted in Uncategorized

My single most used grep command

Often all I need is to find matches in a group of files of a single pattern. But I always forget the grep command for it. This does not come up very often – that’s probably why. In any case, thank you intarwebs for allowing me to have this cheat sheet that is my blog.

The line is:

grep -Riln "pattern-to-search" "path-to-search-directory"

-R is dereference-recursive option, where the search recurses into subdirectories but follows symlinks (use -r if no follow symlinks).

-i ignores case or searches case-insensitive

-l prints only files with pattern search matches

-n prints line numbers with output lines

Advertisements

Author:

I am a software developer located in the Washington, DC Metro Area.

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