grep options

Here are some of the options that can be passed to grep:
-l – Print filename if pattern found otherwise it doesn’t print the filename, if found any one file exit status is 0, if not found in any files then 1
-n – Print line # where pattern was found
-i – ignore case when matching string
-v – Display lines where the given pattern doesn’t match
-c – Display total number of occurrences of pattern found, if multiple occurrences on one line it is counted as one
-s – silent displays except error message, if found then exit status is 0 else non-zero

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