Information Technology Reference
In-Depth Information
Table 6.4
Directory/Filename Metacharacters
Metacharacter
Description
?
Matches any single character
*
Matches zero or more occurrences of any character
[...]
Represents a set of characters of which any one character can
match. User character sets can commonly be represented as ranges.
For example, lowercase letters [a-z], uppercase letters [A-Z], and
numbers [0-9] are frequently used.
An example would best illustrate the use of metacharacters. Given a set of
files: filea , fileb, through filez , the following metacharacter expressions speci-
fied as an argument to the ls command can be used to represent all 26 of
these files:
ls file[abcdefghijklmnopqrstuvwxzy]
ls file[a-ef-jk-op-tu-z]
ls file[a-mn-z]
ls file[a-z]
ls file*
ls file?
Thus metacharacters can be used to reference files that have a common pre-
fix. They can also be used to reference files with a common suffix. For exam-
ple, given a set of C language source code files (that all end with the .c suf-
fix), all of these files can be referenced using the *.c metacharacter (or reg-
ular) expression.
Directory Tree Navigation
When a user logs into the system, the user is positioned somewhere in the
Unix directory tree, typically the home directory of the user account. The
current directory, referred to as the current working directory , can be displayed
using the pwd(1) command.
The user can move around the directory tree using the cd(1) command.
When used without any command-line arguments, the user is relocated to
the directory specified by the HOME shell parameter (or environmental vari-
able). HOME is typically set to the home directory of the user account. A new
directory can be specified as a command-line argument. If the directory
exists and the user has execution permission, the user is relocated to that
directory. The new directory can be specified using complete directory
names, partial directory names and metacharacters, and in most cases all
metacharacters.
Search WWH ::




Custom Search