Wildcards in File Names & DirectoriesOne frustrating activity in Mac OS 9.x and earlier was working with a group of files. Other than Shift-clicking or dragging to select the group, you had no good way to select group items by namefor example, to select all files that started with the characters file and ended with the characters .doc. Unix, however, makes this easy by enabling you to use three special characters as wildcards:
You can place the wildcard wherever you want in the name you are searching for. As you can imagine, wildcards are powerful tools for selecting or listing files or subdirectories.
Using wildcardsThe best way to explain how you can use wildcards is to show you some examples. Suppose your Documents subdirectory contained the following subdirectories and files:
Here are some examples to illustrate the asterisk wildcard (Figure 18):
Figure 18. These examples show how you can use the asterisk wildcard to list specific files in a directory.These examples illustrate the question mark wildcard (Figure 19):
Figure 19. These examples show the question mark wildcard in action. (Both dir1 and dir2 are empty directories; that's why no files are listed for them.)And these examples illustrate the brackets wildcard in action (Figure 20):
Figure 20. Here are two examples for the bracket wildcard.To view a directory list using a wildcardType ls followed by the search string for the files or directories you want to display (see previous examples) and press A list containing only the files and directories that match the search string appear (Figures 18, 19, and 20). |