Open System Services Shell and Utilities Reference Manual (G06.29+, H06.08+, J06.03+)
grep(1) OSS Shell and Utilities Reference Manual
sequence.
A range can include a multicharacter collating element
enclosed within bracket-period delimiters ([. .]). The
bracket-period delimiters in the RE syntax distinguish mul-
ticharacter 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 ele-
ments 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 sorting. 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.
\special_character
A \ (backslash) followed by a special pattern-matching character
matches the special character itself (as a literal character). These spe-
cial pattern-matching characters are as follows:
.*[\ Always special, except when they appear within [](brack-
ets).
^ Special at the beginning of an entire pattern or when it
immediately follows the left bracket of a pair of brackets
([ˆ...]).
$ Special at the end of an entire pattern.
[: :] A character class name enclosed in bracket-colon delimiters matches
any of the set of characters in the named class. Members of each of the
sets are determined by the current setting of the LC_CTYPE environ-
ment variable. The supported classes are alpha, upper, lower, digit,
xdigit, space, print, punct, graph, and cntrl.
Here is an example of how to specify one of these classes:
[[:lower:]]
This matches any lowercase character for the current locale.
Forming Patterns
The following rules describe how to form patterns from REs:
• An RE that consists of a single, ordinary character matches that same
character in a string.
4−28 Hewlett-Packard Company 527188-021