grep

Official Description

Searches a file for patterns.

Syntax

grep [-E  | -F] [-c  | -l  | -q] [-bhinsvwxy]
[-pparagraph_separator] –e pattern_list [-e pattern_list]...
[-f pattern_file]... [file...]

Options

-E functions as an egrep command.

-F functions as an fgrep command.

-c shows a count of matching lines.

-i ignores case.

-l lists filenames.

-v inverts the meaning of the search.

Oddities

The grep command looks to stdin for the data through which to search.

Example

 $ cat buzz #! /bin/ksh integer x=17 while : do x=17 done $ $ cat buzz | grep 17 # Looks through piped data for 17 integer x=17 x=17 $ ls | grep buzz # Looks through piped data for buzz buzz buzz1 buzz2 buzz3 buzz4 $ ls | grep 17 # Looks through piped data for 17, not there $ $ ...

Get Korn Shell Programming by Example 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.