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

fgrep(1) OSS Shell and Utilities Reference Manual
Command Usage
The fgrep command precedes the matched line with the name of the file containing it if you
specify more than one file (except when the -h ag is specified).
Lines are limited to 2048 bytes; longer lines are broken into multiple lines of 2048 or fewer bytes.
Running the fgrep 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 pattern.
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 meaning only if it occurs first in the string.
- You can use a - (dash) to indicate a range of consecutive characters. The char-
acters that fall within a range are determined 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
sequence.
A range can include a multicharacter collating element enclosed within
bracket-period delimiters ([. .]). The bracket-period delimiters in the RE syn-
tax distinguish multicharacter collating elements from a list of the individual
characters that make up the element.
A collating sequence can define equivalence classes for characters. An
equivalence class is a set of collating elements that all sort to the same primary
location. They are enclosed within bracket-equal delimiters ([= =]). An
equivalence class generally is designed to deal with primary-secondary sort-
ing. For example, if e, è, and ê belong to the same equivalence class, then
[[=e=]fg], [[=è=]fg], and [[=ê=]fg] are each equivalent to [eèêfg].
The - (dash) character loses its special meaning if it occurs first ([-string ]), if it
immediately follows an initial circumflex ([ˆ-string]), or if it appears last
([string-]) in the string.
] When the ] (right bracket) is the first character in the string ([]string])
or when
it immediately follows an initial circumflex ([ˆ]string]), it is treated as a part of
the string rather than as the string terminator.
3132 Hewlett-Packard Company 527188-021