The shell allows the user to enter part of a file or several files without typing the filename explicitly. This is called filename substitution and it allows the user to significantly reduce the number of keystrokes entered. For example if someone wanted the listing of all the C source files in the current directory they could type
$ ls *.c
or perhaps all of the C files that start with the letter
$ ls s*.c
* symbol matches a group of characters, but the shell
will also recognize two other substitution symbols for less general
? and the
? symbol is the character replacement.
It will substitute a character into the question mark position of the
string until all matches have been made or all the characters have
been placed in the spot and no matches have been made.
An even more specific substitution exists, the character set
This allows the user to search for a very specific example such as the
$ rm file[a-df].txt
This example deletes the files:
filef.txt, but leaves
filee.txt untouched (if such a file exists).
If the negation symbol
! is used with the character set
substitution, the enclosed characters can be explicitly avoided.
This means that all strings not containing the substring will be
Of course all of these substitution symbols can be used together as