Wildcards and What They Mean
Wait. What? Wildcards? What's that about?
Unless your computing career has encompassed Unix/Linux or MS-DOS, wildcards will be something new to you. They're unique to command-line operating system environments and are also a key part of their usability. Wildcards are what allow you to specify groups of files all at once, based on similarities in their filenames.
The asterisk (*) character can be used to represent any contiguous series of characters, and the question mark (?) can represent any single character. Using these wildcard characters, you can perform repetitive or tedious tasks on large groups of files all at once, instead of having to do it over and over, once per file. For instance, consider the following list of files:
Picture01.jpg Picture02.jpg Picture03.jpg Pics.txt
Suppose you wanted to get a list of only the JPEG files in this directory. That could be accomplished in any of several ways:
Silver:~ btiemann$ ls *.jpg Silver:~ btiemann$ ls Picture0?.jpg Silver:~ btiemann$ ls Pict*
As you can see, wildcards in Unix don't discriminate between the filename and the extension; the asterisk wildcard covers the .jpg part of the affected files as well as the unspecified portion before the period. This differs from the MS-DOS way, in which you had to specify *.* to refer to all the files in a directory. In Mac OS X and other Unixes, you can use * to cover everything.
Another kind of wildcard that gives you more precise control is the brackets (), which lets you specify a set of matching characters (instead of the "any character" that the ? wildcard implies). Any characters specified within the brackets are potential matches. For example:
Silver:~ btiemann$ ls Picture0.jpg Picture01.jpg Picture03.jpg
You might be accustomed to selecting large groups of files in a Finder window, visually, to move or delete them all in one fell swoop. This might seem a more direct solution than wildcards, and in many cases it is. But if the files are all named similarly enough that they can all be described using a wildcard or two, and if the Finder can't group them efficiently, you might find that using the Terminal and wildcards can save you some time over doing it the Finder's way.