Filename Metacharacters
|
Metacharacters |
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 enclosed as above. |
|
|
Expand each comma-separated string inside braces. The strings need not match actual filenames. |
|
|
Home directory for the current user. |
|
|
Home directory of user name. |
|
|
The nth entry in the directory stack, counting from zero. |
|
|
The last entry in the directory stack. |
|
|
Matches anything that
pattern does not match. To work
correctly, pattern must contain
|
Examples
%ls new*Match new and new.1 %cat ch?Match ch9 but not ch10 %vi[D-R]*Match files that begin with uppercase D through R %ls {ch,app}?Expand, then match ch1, ch2, app1, app2 %mv info{,.old}Expands to mv info info.old %cd ~tomChange to tom's home directory %touch aa bb ccCreate some files %ls ^a*List nonmatching filenames bb cc
Tip
On modern systems, ranges such as [D-R] are not portable; the system’s
locale may include more than just the uppercase letters from
D to R in the range.
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