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

User Commands (d - f) egrep(1)
matches 122.
An RE followed by:
\{number\}
Matches exactly number occurrences of the character matched by the RE.
\{number,\}
Matches at least number occurrences of the character matched by the RE.
\{number1,number2\}
Matches any number of occurrences of the character matched by the RE from
number1 to number2, inclusive.
The values of number1 and number2 must be integers in the range 0 through
255. Whenever a choice exists, this pattern matches as many occurrences as
possible.
Note that if number is 0 (zero), pattern matches zero occurrences of pattern.For
example:
$ echo abc | grep aX\{0\}bX\{0\}cX\{0\}
abc
$
You can combine REs into patterns that match strings containing the same sequence of
characters. For example, AB*CD matches the string ABCD, and [A-Za-z]*[0-9]*
matches any string that contains any combination of ASCII alphabetic characters (includ-
ing none), followed by any combination of numerals (including none).
The character sequence \(pattern\) matches pattern and saves it into a numbered holding
space. Using this sequence, up to nine patterns can be saved on a line. Counting from left
to right on the line, the rst pattern saved is placed in the rst holding space, the second
pattern saved is placed in the second holding space, and so on.
The character sequence \n matches the nth saved pattern, which is placed in the nth hold-
ing space. (The value of n is an integer in the range 1 through 9.) Thus, the following pat-
tern:
\(A\)\(B\)C\2\1
matches the string ABCBA. You can nest patterns to be saved in holding spaces.
Whether the enclosed patterns are nested or in a series, \n refers to the nth occurrence,
counting from the left, of the delimiting characters, \).
Restricting What Patterns Match
A pattern can be restricted to match either from the beginning of a line, up to the end of the line, or
the entire line:
A ˆ (circumex) at the beginning of a pattern causes the pattern to match only a string that
begins in the rst character position on a line.
A $ (dollar sign) at the end of a pattern causes that pattern to match only if the last
matched character is the last character (not including the newline character) on a line.
527188-003 Hewlett-Packard Company 353