Wildcards
Wildcards are one of the most powerful features of command shells. With wildcards, you can process all the files that match a particular naming pattern with a single command. For example, suppose that you have a folder with 500 files in it, and you want to delete all the files that contain the letters Y2K and end with .doc, which happens to be 50 files. If you try to do this in GNOME, you'll spend ten minutes picking these files out from the list. From a shell, you can delete them all with the single command rm *Y2K*.doc.
You can use two basic wildcard characters. An asterisk (*) stands for any number of characters, including zero, while an exclamation mark (!) stands for just one character. Thus, !Text.doc matches files with names like aText.doc, xText.doc, and 4Text.doc, but not abcText.doc or just Text.doc. However, *Text.doc would match any of the names I mentioned.
You can also use brackets to indicate a range of characters to choose from. For example, report[123] matches the files report1, report2, or report3. You can also specify report[1-5] to match report1, report2, report3, report4, or report5. The wildcard r[aeiou]port matches files named raport, report, riport, roport, or ruport. As you can see, the possibilities are almost endless.
In this tutorial:
- Linux Commands
- Command Shell Basics
- Editing commands
- Wildcards
- Redirection and piping
- Environment variables
- Shell scripts
- Directory and File Handling Commands
- The cd command
- The mkdir command
- The rmdir command
- The ls command
- The cp command
- The rm command
- The mv command
- The touch command
- The cat command
- Commands for Working with Packages and Services
- The rpm command
- Commands for Administering Users
- The usermod command
- The chage command
- The passwd command
- The newusers command
- The groupadd command
- The groupdel command
- Commands for Managing Ownership and Permissions
- The chgrp command
- The chmod command
- Networking Commands
- The ipconfig command
- The netstat command
- The ping command
- The route command
- The traceroute command