September 19, 2011 | Commands | No Comments|
grep – command provides search in one or more files, lines that match the regular expression (search patterns).
grep [options] pattern files
-N (where N-number) displays the N lines near the line containing the sample.
-c displays the number of lines that contain the search pattern.
-f file Read options from the specified file.
-i ignores case letters.
-l displays the names of files containing the sample.
-n display line numbers next to the lines containing the sample.
-q returns the status code, but nothing prints.
-v print lines not containing the sample.
-w compares only whole words.
The command grep searches for a template in these files. Typically, the grep command used to search a specified sequence of characters in one or more text files.