Sunday, September 22, 2013

Listing all the files with desired word - GREP command

One should get a grip on the Linux grep command. The grep command allows you to search one file or multiple files for lines that contain a pattern. Exit status is 0 if matches were found, 1 if no matches were found, and 2 if errors occurred.

$ grep [options] pattern [files]
-bDisplay the block number at the beginning of each line.
-cDisplay the number of matched lines.
-hDisplay the matched lines, but do not display the filenames.
-iIgnore case sensitivity.
-lDisplay the filenames, but do not display the matched lines.
-nDisplay the matched lines and their line numbers.
-sSilent mode.
-vDisplay all lines that do NOT match.
-wMatch whole word.

No comments:

Post a Comment