4.3 File and Directory Wildcards
When you have a number of files named in series (for example,
chap1
to
chap12
) or filenames with common characters
(like
aegis
,
aeon
, and
aerie
), you can use
wildcards
(also called
metacharacters
) to specify many
files at once. These special characters are * (asterisk),
The examples below demonstrate the use of wildcards. The first command lists all the entries in a directory, and the rest use wildcards to list just some of the entries. The last one is a little tricky; it matches files whose names contain two (or more) a 's.
% Wildcards are useful for more than listing files. Most UNIX commands accept more than one filename, and you can use wildcards to put multiple files on the command line. For example, the command more is used to display a file on the screen. Let's say you want to display files chap3.old and chap1a.old . Instead of specifying these files individually, you could enter the command as:
% This is equivalent to " more chap1a.old chap3.old ". Wildcards match directory names, too. For example, let's say you have subdirectories named Jan , Feb , Mar , and so on. Each has a file named summary . You could read all the summary files by typing " more */summary ". That's almost equivalent to " more Jan/summary Feb/summary ..." but there's one important difference: The names will be alphabetized, so Apr/summary would be first in the list. |
|