
Metacharacters | 699
Pattern
Matching
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Linux allows the use of POSIX “character classes” within the square brackets that
enclose a group of characters. They are typed enclosed in
[: and :]. For example,
[[:alnum:]] matches a single alphanumeric character.
Finally, the GNU utilities on Linux accept additional escape sequences that act
like metacharacters. (Because \b can also be interpreted as the sequence for the
ASCII Backspace character, different utilities treat it differently. Check each
utility’s documentation.)
Replacement Patterns
The characters in the following table have special meaning only in replacement
patterns.
? Match zero or one instances of preceding regular expression.
| Match the regular expression specified before or after the vertical bar (alternation).
( ) Apply a match to the enclosed group of regular expressions.
Class Characters matched Class Characters matched
alnum Alphanumeric characters lower Lowercase characters
alpha Alphabetic characters print Printable characters
blank Space or Tab punct Punctuation characters
cntrl Control characters space Whitespace characters
digit Decimal digits upper Uppercase characters
graph Non-space characters xdigit Hexadecimal digits
Sequence Meaning
\b Word boundary, either beginning or end of a word, as for the \< and \> metacharacters ...