Skip to main content
IBM 
ShopSupportDownloads
IBM HomeProductsConsultingIndustriesNewsAbout IBM
IBM : developerWorks : Linux : Education - Tutorials
LPI certification 101 exam prep, Part 1
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
5. Introducing wildcards
  


Wildcard syntax: [] page 7 of 11



[]

This wildcard is like a ?, but allows more specificity. To use this wildcard, place any characters you'd like to match inside the []. The resultant expression will match a single occurrence of any of these characters. You can also use - to specify a range, and even combine ranges. Examples:

  • myfile[12] will match myfile1 and myfile2. The wildcard will be expanded as long as at least one of these files exists in the current directory.
  • [Cc]hange[Ll]og will match Changelog, ChangeLog, changeLog, and changelog. As you can see, using bracket wildcards can be useful for matching variations in capitalization.
  • ls /etc/[0-9]* will list all files in /etc that begin with a number.
  • ls /tmp/[A-Za-z]* will list all files in /tmp that begin with an upper or lower-case letter.

Main menuSection menuFeedbackPreviousNext
PrivacyLegalContact