Metacharacters
The following characters have special meaning in search patterns:
Character | Meaning |
---|---|
.
| Match any single character except newline. |
*
|
Match any number (or none) of the single character that immediately precedes it. The preceding character also can be a regular expression (e.g., since . (dot) means any character, .* means match any number of any character—except newlines). |
^
|
Match the beginning of the line or string. |
$
|
Match the end of the line or string. |
[ ]
|
Match any one of the enclosed characters. A hyphen (-) indicates a range of consecutive characters. A circumflex (^) as the first character in the brackets reverses the sense: it matches any one character not in the list. A hyphen or close bracket (]) as the first character is treated as a member of the list. All other metacharacters are treated as members of the list. |
[^ ]
|
Match anything except enclosed characters. |
\{
n ,m
\}
|
Match a range of occurrences of the single character
that immediately precedes it.
The preceding character also can be a regular expression.
\{ |
{
n ,m
}
|
Like
|
\
|
Turn off the special meaning of the character that follows. |
\(\)
|
Save the matched text enclosed between \( and \) in a special holding space. Up to nine patterns can be saved on a single ... |
Get Linux in a Nutshell, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.