The grep command supports regular expressions that are combinations of one or more of the following:
c |
Any ordinary character, other than one of the special pattern-matching characters, matches itself. |
. |
A . (period) matches any single character. |
[string] |
A string enclosed in square brackets matches any one character in the string. |
[.-.] |
A range is two characters separated by a dash and enclosed in square brackets. It matches any character that is within the range. |
[^string] |
A string (or range) enclosed in square
brackets and preceeded by a ^ (circumflex)
matches any character except for the characters in
the string (or range).
Strings and ranges may be combined as needed, as
in: |
\c |
The \ (backslash) followed by any character
matches that character. This is useful for matching
the following special characters:
. * [ ] { } ^ $ \ |
* |
Matches zero or more occurences of the previous character. |
{m} |
Matches exactly m occurrences of the previous character. |
{m,} |
Matches at least m occurrences of the previous character. |
{m,n} |
Matches at least m but no more than n occurrences of the previous character. m and n must be integers from 0 to 255, inclusive. |
^pattern |
The pattern matches a string that begins on the first character of a line. |
pattern$ |
The pattern matches a string that ends on the last character of a line. |
^pattern$ |
The pattern matches an entire line. |