Imagine that you have the following files12 pictures and a text filein a directory on your computer: libby1.jpg libby2.jpg libby3.jpg libby4.jpg libby5.jpg libby6.jpg libby7.jpg libby8.jpg libby9.jpg libby10.jpg libby11.jpg libby12.jpg libby1.txt You want to delete these files using the rm command (covered in Chapter 2) on your command line. Removing them one at a time would be tedious and kind of silly. After all, one of the reasons to use computers is to automate and simplify boring tasks. This is a job for wildcards, which allow you to specify more than one file at a time by matching characters. There are three wildcards: * (asterisk), ? (question mark), and [ ] (square brackets). Let's take each one in order. The * matches any character zero or more times. Table 1.2 has some uses of the * and what they would match.
The ? matches a single character. Table 1.3 has some uses of the ? and what they would match.
The [ ] match either a set of single characters ([12], for instance) or a range of characters separated by a hyphen (such as [1-3]). Table 1.4 has some uses of the [ ] and what they would match.
You'll be using wildcards all through this book, so it's good to introduce them now. They make dealing with files on the command line that much easier, and you're going to find them extremely helpful. |