Open System Services Shell and Utilities Reference Manual (G06.28+, H06.05+)

grep(1) OSS Shell and Utilities Reference Manual
NAME
grep - Search a le for a pattern
SYNOPSIS
grep [-E | -F][-c | -l | -q][-bhinsvwxy][-pparagraph_separator ...]
{pattern ... | -e pattern ... | -f pattern_le ...} [le ... ]
FLAGS
While most ags can be combined, some combinations result in one ag overriding another. For
example, if you specify the -n and -l ags, the output includes lenames only (as specied by the
-l ag) and thus does not include line numbers (as specied by the -n ag).
-b Precedes each line by the block number in which it was found. Use this ag to help
nd disk block numbers by context.
-c Displays only a count of matching lines.
-e pattern ...
Species a pattern. This ag 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 ...
Species a le that contains patterns. Each pattern terminates with a newline charac-
ter.
-F Uses xed 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 lenames when multiple les 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 ag).
-l Lists the name of each le with lines matching pattern. Each lename is listed only
once; lenames are separated by newline characters.
-n Precedes each line with its relative line number in the le.
-pparagraph_separator ...
Displays the entire paragraph containing matched lines. Paragraphs are delimited by
paragraph separators specied 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 per-
mitted between the ag 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 les. When searching several
les, it provides a performance improvement because it can quit as soon as it nds the
rst match, and it requires less care by the user in choosing the set of les 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 le arguments.
-s Suppresses error messages about inaccessible les.
-v Displays all lines except those that match the specied pattern. This ag is useful for
ltering unwanted lines out of a le.
424 Hewlett-Packard Company 527188-007