grep

Globally find R.E. patterns and print (display) that line

Usage: grep R.E.pattern [list-of-files]

Standard Input: Used only if no list-of-files is given

Standard Output: Used to display results

See wildcards for regular expressions.

SEE ALSO

For more information, see page 494

Useful options:

-c means to display just filenames and count of lines that contain the pattern.

-i means to ignore upper/lowercase.

-l means just list the filenames that contain the pattern.

-n means to include the line number with each line displayed.

-v means to reverse the test; show lines that do not contain the pattern.

-y same as -i, but only on older UNIX systems.

Get Practical UNIX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.