MPE/iX Shell and Utilities Reference Manual, Vol 1

grep(1) MPE/iX Shell and Utilities grep(1)
NAME
grep, egrep, fgrep — match patterns in a file
SYNOPSIS
egrep [–bcilnqsvx][–e pattern] ... [–f patternfile] ... [pattern][file ...]
fgrep [–bcilnqsvx][–e pattern] ... [–f patternfile] ... [pattern][file ...]
grep [–bcEFilnqsvx][–e pattern] ... [–f patternfile] ... [pattern][file ...]
DESCRIPTION
fgrep searches files for one or more pattern arguments. It does not use regular expressions;
instead, it does direct string comparison to find matching lines of text in the input.
egrep works in a similar way, but uses extended regular expression matching, as described in
regexp(3). If you include special characters in patterns typed on the command line, escape
them by enclosing them in apostrophes to prevent inadvertent misinterpretation by the shell or
command interpreter. To match a character that is special to egrep, put a backslash (\)in
front of the character. It is usually simpler to use fgrep when you don’t need special pattern
matching.
grep is a combination of fgrep and egrep. If you do not specify either –E or –F, grep
behaves like egrep, but matches basic regular expressions instead of extended ones. You
can specify a pattern to search for with either the –e or –f option. If you specify neither
option, grep (or egrep or fgrep) takes the first non-option argument as the pattern for
which to search. If grep finds a line that matches a pattern, it displays the entire line. If you
specify multiple input files, the name of the current file precedes each output line.
Options
grep accepts all of the following options while egrep and fgrep accept all but the –E and
–F options.
–b precedes each matched line with its file block number.
–c displays only a count of the number of matched lines and not the lines themselves.
–E causes grep to behave like egrep.
–e pattern
specifies one or more patterns separated by newlines for which grep is to
search.
–F causes grep to behave like fgrep.
–f patternfile
reads one or more patterns from patternfile. Patternsinpatternfile are separated by
newlines.
Commands and Utilities 1-259