GnomeTWEAK
- 0
- Add a Comment
- No Related Post
|
GnomeTWEAK |
|
TWEAK YOUR SYSTEM: You’ve tweaked your user interface until it’s truly yours; now tweak the components that make up your system. These parts look like nothing you’ve ever seen. Bay Bus Kits, Aluminum Cases, Light Kits, Window Kits, Case Handles, Etched Window Appliques, pcMods.com has all this and more. Click here To add something different to your PC. |
Using Wildcards in File Operations
So you’re looking for a file on your system. You’re not exactly sure what it’s called, and getting it right (case included) is critical in Linux. Or, you’re looking for several files that have similar names. Or, you want to remove all the files in your /home/user/bin directory that start with lower case characters. What do you do? You tweak your commands, of course, using wildcards.
There are three fundamental wildcard types in command line searches - multiple character, single character and character groups. Let’s take a quick look at all three.
The multiple character searches are implemented using the *. This search character simply means, “show me any number of characters - it could be anything.” This is the broadest type of search. Enter the following command for an example:
locate bin*
It returns a ton of results. You’ll notice that all the results contain the “bin” string with additional following characters. You can also see that these results can be recursive within directories. In other words, the “bin” string may, in fact, be a directory, followed by the remainder of the path.
Single character searches utilize the ?. This refines to search to look for your string with only one additional character. The wildcard character can even be between other characters.
cat cd?ackup.sh
While not very practical, this search shows that the wildcard will cat any file with cd followed by any letter followed by ackup.sh. Again, it’s a single character wildcard.
Character group searches use the [] symbols to enclose the group of wildcard characters.
cp [abcde]*.sh
This command would copy all files starting with a lowercase a, b, c, d, or e, followed by any number of characters and ending in .sh.
With character groups, you can even use other operands - ! (not) and - (intervals).
cp [!abcde]*.sh
This command performs the opposite action of the previous one; it copies any file that doesn’t start with a, b, c, d, or e.
rm [a-e]*.sh
This command would remove any files that start with a lower case a through e, followed by any other letters, and ending in .sh.
ls -l [!a-eA-E]*.sh
… would return a listing of a files that don’t start with either lower or upper case characters a through e.
Wildcards make many of your favorite commands in Linux much more flexible and efficient. If you want to perform operations on groups of files, the right wildcard can be a useful tools to use.
