Filename Metacharacters
|
Characters |
Meaning |
|
|
Match any string of zero or more characters. |
|
|
Match any single character. |
|
|
Match any one of the enclosed characters; a hyphen can be used to specify a range (e.g., a-z, A-Z, 0-9). |
|
|
Match any character not among the enclosed characters. |
|
|
Same as [! |
|
|
Brace expansion: match any of the enclosed strings. |
|
|
Home directory of user name. With no name, Home directory of current user. |
|
|
Current working directory (PWD). |
|
|
Previous working directory from directory stack (OLDPWD; see also the pushd built-in command). |
|
|
The nth entry in the directory stack, counting from the start of the list with the first entry being 0. |
|
|
The nth entry in the directory stack, counting from the end of the list with the last entry being 0. |
Patterns can be a sequence of patterns separated by |. If any subpatterns match, the entire sequence is considered matching. This extended syntax resembles that of egrep and awk.
Examples
$ ls new* List new and new.1 $ cat ch? Match ch9 but not ch10 $ vi [D-R]* Match files that begin with uppercase D through R
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access