The primary wildcards used in shell environments are the asterisk (*), question mark (?), and square brackets ([]). However, there are additional patterns and constructs that can be useful:
-
Exclamation Mark (
!): Used within square brackets to negate a character class. For example,file[!1].txtwill match any file that does not have1as the character in that position. -
Double Asterisk (
**): In some shells (like Bash withshopt -s globstarenabled), it matches directories recursively. For example,**/*.txtwill match all.txtfiles in the current directory and all subdirectories. -
Tilde (
~): Represents the home directory of the current user. While not a wildcard in the traditional sense, it can be used in path expansions.
These constructs can enhance your file matching capabilities in shell scripting and command-line operations.
