Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)

grep(1) OSS Shell and Utilities Reference Manual
NAME
grep - Search a file for a pattern
SYNOPSIS
grep [-E | -F][-c | -l | -q][-bhinsvwxy][-pparagraph_separator ...]
{pattern ... | -e pattern ... | -f pattern_file ...} [file ... ]
FLAGS
While most flags can be combined, some combinations result in one flag overriding another. For
example, if you specify the -n and -l ags, the output includes filenames only (as specified by the
-l flag) and thus does not include line numbers (as specified by the -n ag).
-b Precedes each line by the block number in which it was found. Use
this flag to help find disk block numbers by context.
-c Displays only a count of matching lines.
-e pattern ...
Specifies a pattern. This flag works the same as a simple pattern but is
useful when the pattern begins with a - (dash).
-E Uses extended regular expressions (EREs) to match patterns (treats
each pattern as an ERE). A null ERE matches every line.
-f pattern_file ...
Specifies a file that contains patterns. Each pattern terminates with a
newline character.
-F Uses fixed strings to match patterns (treats each pattern as a literal
string instead of as a regular expression). A null string matches every
line.
-h Suppresses reporting of filenames when multiple files are processed.
-i Ignores the case of letters in locating pattern; that is, uppercase and
lowercase letters in the input are considered identical (same as the -y
flag).
-l Lists the name of each file with lines matching pattern. Each filename
is listed only once; filenames are separated by newline characters.
-n Precedes each line with its relative line number in the file.
-pparagraph_separator ...
Displays the entire paragraph containing matched lines. Paragraphs
are delimited by paragraph separators specified by
paragraph_separator, which is a BRE pattern. Lines containing the
paragraph separators are used only as separators; they are never
included in the output. The default paragraph separator is a blank line.
No space is permitted between the flag and the paragraph separator.
-q Suppresses all output except error messages. This is useful for easily
determining whether or not a pattern or string exists in a group of files.
When searching several files, it provides a performance improvement
because it can quit as soon as it finds the first match, and it requires
less care by the user in choosing the set of files to supply as arguments
because it exits with a 0 (zero) exit status if it detects a match, even if
the grep command detected an access or read error on earlier file
426 Hewlett-Packard Company 527188-021