E-Mail:
Author Avatar

Characters Are Wild

Characters Are Wild

I know we’ve talked a bunch about searching for files, strings and patterns in Linux. As you start to get comfortable with the shell and move around within it more and more, these commands really start to show their power. I want to take a paragraph or two to mention yet another ‘matching’ feature in Linux that will become more useful as you go. Just like the one-eyed jack in a game of Montana Red Dog, today’s GnomeTWEAK is on wildcards.

Wildcards in Linux, as in Windows, are useful for searching files or groups of files based on a single character or a group of characters. If you remember only part of a filename, or want to find a group of files with a common extension, wildcards are invaluable. Let’s talk first about single character wildcards in Linux,

Wildcard Matches
* Any characters
? Any single character
[characters] Any character that’s a member of the [set]
![characters] Any character that’s not a member of the [set]

This looks, and really is, pretty simple. Using single wildcards can be useful, but the real power of wildcards lies in putting together patterns for searching.

Pattern Matches
* All files
x* All files beginning with the letter x
*.rpm All files ending with the .rpm extension
bash?? All files that start with bash and end with two characters
[abc]* All files that begin with a, b or c and end with any other characters
[A-Z]* Any filename that begins with an uppercase letter followed by any other characters
DAILY.[0-9][0-9][0-9] Any file starting with DAILY containing an extension with any 3 numbers
![a-z]* Any filename that doesn’t begin with a lower case letter

Used with our old favorite “find” command, wildcards can be a real timesaver when searching for files.

What Do You Think?

 


Anti-Spam Image

Want to Start a Blog Here for Free?

Are you an expert in one subject or another? If your goal is to help others and dispense hard-earned information back to the community, stake a claim on your very own Lockergnome blog today! You can write about anything - no matter the topic. Sign-up to start blogging!

Author Avatar
Interview, Linux, Misc - Dec 19, 2007

KOffice vs OOXML: Practical, Not Political

Author Avatar
Myths - Dec 3, 2007

5 Myths That Stymie Linux Growth

Author Avatar
Just Ask Matt - Linux Edition - Nov 20, 2007

Default Sound Card Not Sticking In Ubuntu!