Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)
User Commands (g - j) grep(1)
arguments.
-s Suppresses error messages about inaccessible files.
-v Displays all lines except those that match the specified pattern. This
flag is useful for filtering unwanted lines out of a file.
-w Searches for the expression as a word (the pattern bracketed by nonal-
phanumeric characters or by the beginning or end of the line). See the
reference page for the ex command.
-x Displays lines that match the pattern exactly with no additional charac-
ters.
-y Ignores the case of letters in locating pattern; that is, uppercase and
lowercase letters in the input are considered to be identical (same as
the -i flag).
DESCRIPTION
The grep command searches the specified files (the standard input file by default) for lines con-
taining characters that match the specified pattern and then write matching lines to standard out-
put.
The grep command searches for patterns that are limited regular expressions as described under
Regular Expressions (REs).
Command Usage
The grep command precedes the matched line with the name of the file containing it if you
specify more than one file (except when the -h flag is specified).
Lines are limited to 2048 bytes; longer lines are broken into multiple lines of 2048 or fewer
bytes. Paragraphs (under the -p flag) are currently limited to a length of 5000 bytes.
Running the grep command on a nontext file (for example, an .o file) produces unpredictable
results and is discouraged.
Regular Expressions (REs)
Regular expressions (REs) cannot contain newline characters, because these signal a new pat-
tern. The following REs match a single character:
character
An ordinary character (one other than one of the special pattern-
matching characters) matches itself.
. A . (dot) matches any single character except the newline character.
[string] A string enclosed in [](brackets) matches any one character in that
string. In addition, certain pattern-matching characters have special
meanings within brackets:
^ If the first character of string is a ˆ (circumflex), the RE
[ˆstring] matches any character except the characters in
string and the newline character. A ˆ has this special mean-
ing only if it occurs first in the string.
- You can use a - (dash) to indicate a range of consecutive
characters. The characters that fall within a range are deter-
mined by the current collating sequence, which is defined by
the LC_COLLATE environment variable. For example, [a-
d] is equivalent to [abcd] in the traditional ASCII collating
527188-021 Hewlett-Packard Company 4−27