File name expansion in the C shell
The asterisk (*
) character matches any string
of characters, including the null string.
For example, in a directory containing the files:
a aa aax alice b bb c cc
the
command echo a* prints all files names beginning with the
character a
: a aa aax alice
Note: When
file names are matched, the characters dot (
.
) and slash
(/
) must be matched explicitly.The question mark (
?
) character matches
any single character. The following command: ls a?x
lists
every file name beginning with the letter a
, followed by
a single character, and ending with the letter x
: aax
To match a single character or a range of characters,
enclose the character or characters inside of
[ ]
. The following
command: ls [abc]
lists
all file names exactly matching one of the enclosed characters: a b c
Within brackets, a lexical range of characters is indicated
by [a-z]
. The characters matching this pattern are defined
by the current collating sequence.