grep(1)

 

 

 

grep(1)

Ken

112

Warring

St. Apt. A

Judy

387

Bowditch

Apt.

12

Ann

429

Sixth St.

 

the command:

 

 

 

grep

Judy

address

 

 

prints:

 

 

 

 

Judy

387

Bowditch

Apt.

12

To search a ®le for lines that contain either a Dec or Nov, use either of the following commands:

grep -E '[Dd]ec[Nn]ov' ®le egrep -i 'decnov' ®le

Search all ®les in the current directory for the string xyz:

grep xyz *

Search all ®les in the current directory subtree for the string xyz, and ensure that no error occurs due to ®le name expansion exceeding system argument list limits:

find . -type f -print xargs grep xyz

The previous example does not print the name of ®les where string xyz appears. To force grep to print ®le names, add a second argument to the grep command portion of the command line:

find . -type f -print xargs grep xyz /dev/null

In this form, the ®rst ®le name is that produced by find, and the second ®le name is the null ®le.

WARNINGS

(XPG4 only.) If the -qoption is speci®ed, the exit status will be zero if an input line is selected, even if an error was detected. Otherwise, default actions will be performed.

If the -woption is speci®ed with non-word constituent characters, then the output is unexpected.

SEE ALSO

sed(1), sh(1), regcomp(3C), environ(5), lang(5), regexp(5).

STANDARDS CONFORMANCE

grep: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

egrep: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

fgrep: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

g

HP-UX Release 11i: December 2000

− 3 −

Section 1341