Filename Globbing
Before the shell passes arguments to an
external command or interprets a built-in command, it scans the
command line for certain special characters and performs an operation
known as filename globbing
. Filename globbing
resembles the processing of wildcards used in MS-DOS commands, but
it’s much more sophisticated. Table 13-1
describes the special characters used in filename globbing, known as
filename metacharacters
.
Table 13-1. Filename Metacharacters
Metacharacter |
Function |
---|---|
|
Matches a string of zero or more characters |
|
Matches exactly one character |
|
Matches any of the characters specified |
|
Matches any character in the specified range |
|
Matches any character other than those specified |
|
Matches any character not in the specified range |
|
The home directory of the current user |
|
The home directory of the specified user |
|
The current working directory |
|
The previous working directory |
In filename globbing, just as in MS-DOS wildcarding, the shell attempts to replace metacharacters appearing in arguments in such a way that arguments specify filenames. Filename globbing makes it easier to specify names of files and sets of files.
For example, suppose the current working directory contains the
following files: file1
,
file2
, file3
, and
file04
. Suppose you want to know the size of
each file. The following command reports that information:
ls -l file1 file2 file3 file04
However, ...
Get Learning Red Hat Linux, Second 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.