16.12.2012 Views

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

z/OS V1R9.0 UNIX System Services Command ... - Christian Grothoff

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

grep<br />

Options<br />

egrep works in a similar way, but uses extended regular expression matching. (For<br />

information about regular expression matching, see Appendix C.) If you include<br />

special characters in patterns typed on the command line, escape them by<br />

enclosing them in apostrophes to prevent inadvertent misinterpretation by the shell<br />

or command interpreter. To match a character that is special to egrep, put a<br />

backslash (\) in front of the character. It is usually simpler to use fgrep when you<br />

don’t need special pattern matching.<br />

grep is a combination of fgrep and egrep. If you do not specify either –E or –F,<br />

grep behaves like egrep, but matches basic regular expressions instead of<br />

extended ones. You can specify a pattern to search with either the –e or –f option.<br />

If you do not specify either option, grep (or egrep or fgrep) takes the first<br />

non-option argument as the pattern for which to search. If grep finds a line that<br />

matches a pattern, it displays the entire line. If you specify multiple input files, the<br />

name of the current file precedes each output line.<br />

grep accepts all the following options while egrep and fgrep accept all but the –E<br />

and –F options.<br />

–b Precedes each matched line with its file block number.<br />

–c Displays only a count of the number of matched lines and not the lines<br />

themselves.<br />

–E Matches using extended regular expressions (causes grep to behave like<br />

egrep).<br />

–e pattern<br />

Specifies one or more patterns separated by newlines for which grep is to<br />

search.<br />

You can indicate each pattern with a separate –e option character, or with<br />

newlines within pattern. For example, the following two commands are<br />

equivalent:<br />

grep –e pattern_one –epattern_two file<br />

grep –e 'pattern_one<br />

pattern_two' file<br />

–F Matches using fixed strings (causes grep to behave like fgrep).<br />

–f patternfile<br />

Reads one or more patterns from patternfile. Patterns in patternfile are<br />

separated by newlines.<br />

–i Ignores the case of the strings being matched.<br />

–l Lists only the filenames that contain the matching lines.<br />

–n Precedes each matched line with its fileline number.<br />

–q Suppresses output and returns the appropriate return code.<br />

–s Suppresses the display of any error messages for nonexistent or<br />

unreadable files.<br />

–v Complements the sense of the match—that is, displays all lines not<br />

matching a pattern.<br />

–x Requires a string to match an entire line.<br />

304 z/<strong>OS</strong> <strong>V1R9.0</strong> <strong>UNIX</strong> <strong>System</strong> <strong>Services</strong> <strong>Command</strong> Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!