[prev] [index] [next]

grep: select lines matching a pattern

The grep command only copies to output those lines in the input that match a specified pattern.

The pattern is supplied as a regular expression on the command line (and should be quoted using single-quotes).

Some options:

-i ignore upper/lower-case difference in matching
-w only match pattern if it makes a complete word
-v only display lines that do not match the pattern

(The name grep is an acronym for Globally search with Regular Expressions and Print)