You probably already use globbing characters without knowing it. When you specify a file in Windows or when you look for a file, you use * to match a random string. For example, *.txt matches all files with names ending in .txt. We also used it heavily in the last section. But there is more to globbing than *.
When you type a command like ls *.txt and press Return, the task of finding which files match the pattern *.txt is not done by the ls command, but by the shell itself. This requires a little explanation about how a command line is interpreted by the shell. When you type:
$ ls *.txt readme.txt recipes.txt |
? matches one and only one character, regardless of what that character is;
[...] matches any character found in the brackets; characters can be referred to either as a range of characters (e.g, 1-9) or discrete values, or even both. Example: [a-zBE5-7] will match all characters a to z, a B, a E, a 5, a 6 or a 7;
[!...] matches any character not found in the brackets. [!a-z], for example, will match any character which is not a lowercase letter;
{c1,c2} matches c1 or c2, where c1 and c2 are also globbing patterns.
Here are some patterns and their meaning:
/etc/*conf All files in the /etc directory with names ending in conf. It can match /etc/inetd.conf, /etc/conf.linuxconf, and also /etc/conf if such a file exists. Remember that * can also match an empty string.
image/cars,space[0-9]/*.jpg All filenames ending with .jpg in the directories image/cars, image/space0, ... , image/space9, if those directories exist.
/usr/doc/*/README All files named README in all immediate subdirectories of the /usr/doc directory. This will make /usr/doc/mandrake/README match for example, but not /usr/doc/myprog/doc/README.
*[!a-z] All files with names that do not end with a lowercase letter in the current directory.