grep Looks for text within files. For example:
grep this_word this_file.txt
|
Example options:
-
-v --- this option is used to display lines which do not contain the string.
-
-n --- this option displays the line numbers
-
-w --- this option makes grep match the whole word
-
-A x or -B x (where x is a number) --- display "x" lines After or Before the section where the particular word is found.
-
-r or rgrep --- search for text within files recursively.
This command uses regular expressions, for more information please see, Section 20.4.2.
For example, this command would look in the file "rpmlist.txt" for anything starting with "rpm":
Or you could use it like this, to search through the output of another file:
The first command lists all RPM's installed on your system, the second finds any containing the string "ogg" and outputs them.