Wildcards
Wildcards provide a shorthand for specifying sets of files with similar names. For example, a* means all files whose names begin with lowercase “a”. Wildcards are “expanded” by the shell into the actual set of filenames they match. So if you type:
$ ls a*
the shell first expands a* into the filenames that begin with “a” in your current directory, as if you had typed:
ls aardvark adamantium apple
ls never knows you used a wildcard: it sees only the final list of filenames after the shell expansion.
Wildcard | Meaning | |
* | Any set of characters except a leading period | |
? | Any single character | |
[ | Any single character in the given | |
[ [ | Any single character not in the given |
When using sets, if you want to include a literal dash in the set, put it first or last. To include a literal closing square bracket in the set, put it first. To include a ^ or ! literally, don’t put it first.