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

User Commands (g - j) grep(1)
An RE followed by an * (asterisk) matches zero or more occurrences of
the character that the RE matches. For example, the following pattern:
ab*cd
matches each of the following strings:
acd
abcd
abbcd
abbbcd
but not the following string:
abd
If there is any choice, the longest matching leftmost string is chosen. For
example, given the following string:
122333444
the pattern .* matches 122333444, the pattern .*3 matches 122333, and
the pattern .*2 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, inclusive. 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 combi-
nation of ASCII alphabetic characters (including 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 first pattern
saved is placed in the first holding space, the second pattern is placed in
the second holding space, and so on.
527188-021 Hewlett-Packard Company 429