Wildcards Flashcards
What is a wildcard?
a character or string used for pattern matching
What is globbing?
The expansion of wildcards patterns into a list of files or directories
*-
A wildcard for trying to match one or more characters
?
a wildcard for matching exactly one charater
[]
Matches exactly one character in the brackets []
eg:
ca[nt]
-cat (yes)
-can (yes)
-candy (yes)
-catch (yes)
-cap (no)
[!]
Match any one thing in the bracket that is NOT in a file
[a-g]*
Match all the characters that are in the range
[[:alpha:]]
Matches alphabetical characters (lower and upper)
[[:alnum:]]
letters and decimal digits
[[:digit:]]
0-9
[[:lower:]]
lowercase letters
[[:space:]]
Whitespace (tabs, newline, space)
[[:upper:]]
uppercase letters
How do you match wildcard characters?
Use an \
ls *.txt
Lists everything with .txt