4.3.1.3. Ambiguous filenames
The wildcard characters ? and * can be used for pattern matching , which is useful for dealing with several files at a time without individually specifying each filename. ? will match any one character in a filename, and * will match any number of any characters (including none).
Square brackets [] can be used to contain a list of characters [123] , a range of characters [aj] , or a combined list and range [123aj] ; this pattern will match any one character from the list or range. Using an exclamation mark or carat symbol as the first character inside the square brackets will invert the meaning, causing a match with any one character which is not in the list or range.
Table 4-6 lists some examples of ambiguous filenames.
Table 4-6. Ambiguous filenames
Filename | Description | Matches | Does not match |
---|---|---|---|
a* | Any filename starting with a | absolutely.txt | Albert |
a.out | backup | ||
albert | _abc_ | ||
*x* | Any filename containing an x | xylophone.gif | constantinople |
nexus | ALEX | ||
old.x | |||
*[09] | Any filename ending in a digit | file3 | file |
menu.backup60 | file3a | ||
file3.txt | |||
416-555-1212.phone | |||
[Aa]???.txt | Any eight-character filename starting with a or A and ending in .txt | appl.txt | application.txt |
ax42.txt | a.txt | ||
Any1.txt | allow.txt | ||
[azAZ][09] | Any two-character filename starting with a letter and ending with a digit | a9 | No |
G7 | 7G | ||
N3 | XX | ||
Fortran77 | |||
[!azAZ]* | Any filename that does not start with a letter | 9lives.odt | abc.txt |
[^azAZ]* | _whatever | Nevermore |