These shortcuts are useful because they minimize keystrokes. While minimizing keystrokes may seem to be a minor concern at first glance, an administrator who issues lengthy and complex command lines repeatedly may find these shortcuts a handy and necessary time-saving feature.
The following is a list of the IRIX metacharacters:
Metacharacter | Meaning |
---|---|
* | wildcard |
? | single character wildcard |
[] | set definition marks |
The asterisk (*) metacharacter is a universal wildcard. This means that the shell interprets the character to mean any and all files. For example, the command:
tells the shell to concatenate all the files in a directory, in alphabetical order by filename. The command:cat *
tells the shell to remove everything in the directory. Only files will be removed, though, since a different command, rmdir(1) is used to remove directories. However, the asterisk character does not always have to refer to whole files. It can be used to denote parts of files as well. For example, the command:rm *
will remove all files with the suffix.old on their names.rm *.old
The single character wildcard is a question mark (?). This metacharacter is used to denote a wildcard character in one position. For example, if your directory contains the following files:
and you wish to remove file1, file2, and file3, but not file.different, you would use the command:file1
file2
file3
file.different
If you used an asterisk in place of the question mark, all your files would be removed, but since the question mark is a wildcard for a single space, your desired file is not chosen.rm file?
Square brackets denote members of a set. For example, consider the list of files used in the example of the single character wildcard. If you wanted to remove file1 and file2, but not file3 or file.different, you would use the following command:
This command tells the shell to remove any files with names starting with file and with the character 1 or 2 following, and no other characters in the name. Each character in the brackets is taken separately. Thus, if our example directory had included a file named file12, it would not have been removed by the above command. You can also use a dash (-) to indicate a span of characters. For example, to remove file1, file2, and file3, use the following command:rm file[12]
Alphabet characters can be spanned as well, in alphabetical order. The shell does pay attention to upper case and lower case letter, though, so to select all alphabet characters within square brackets, use the following syntax:rm file[1-3]
You can use the square brackets in combination with other metacharacters as well. For example, the command:[a-z,A-Z]
removes any files with names ending with a 2 or 3, but not file1 or file.different.rm *[2,3]