Wildcards in Linux
The shell feature that makes these commands so powerful is – Wildcards.
Because the shell uses file- names so much, it provides special characters to help you rapidly specify groups of filenames. These special characters are called wildcards. Using wildcards (also known as globbing) allows you to select filenames based on patterns of characters.
What wildcards are selecting.
Any single character
Any character that is a member of the set characters
Any character that is not a member of the set characters
Any character that is a member of the specified class
The next table lists the most commonly used character classes.
Commonly Used Character Classes
|[:alnum:]||Any alphanumeric character|
|[:alpha:]||Any alphabetic character|
|[:lower:]||Any lowercase letter|
|[:upper:]||Any uppercase letter|
Using wildcards makes it possible to construct very sophisticated selection criteria for filenames.
Next lists some examples of patterns and what they match.
|g*||Any file beginning with g|
|b*.txt||Any file beginning with b followed by any characters and ending with .txt|
|Data???||Any file beginning with Data followed by exactly three characters|
|[abc]*||Any file beginning with either a, b, or c|
|BACKUP.||Any file beginning with BACKUP. followed by|
|[0-9][0-9][0-9]||Exactly three numerals|
|[[:upper:]]*||Any file beginning with an uppercase letter|
|[![:digit:]]*||Any file not beginning with a numeral|
|*[[:lower:]123]||Any file ending with a lowercase letter or the numerals 1, 2, or 3|
Wildcards can be used with any command that accepts filenames as arguments.