char* | char* "?" | char* "" | char "?" | char* "" | "{" char "," char* "}" | "{" char* "," char* "," char* "}" | "[" char* "-" char* "]" | "[" char* "-" char* "]" | "[" char* "]" | "[" char* "]"
Where:
char is any character except \*, ?, [, ], {, }, ", or '
.
Examples
The following table shows some examples of glob patterns and their meanings:
Pattern | Meaning |
---|---|
\* | Matches any sequence of characters. |
? | Matches any single character. |
\*.txt | Matches any file with a .txt extension. |
\*.c? | Matches any file with a .c extension and a single character following the .c. |
?\*.txt | Matches any file with a .txt extension and a single character preceding the .txt. |
[a-z]\*.txt | Matches any file with a .txt extension and a filename that starts with a lowercase letter. |
[0-9]\*.txt | Matches any file with a .txt extension and a filename that starts with a number. |
[!0-9]\*.txt | Matches any file with a .txt extension and a filename that does not start with a number. |
{a,b}\*.txt | Matches any file with a .txt extension and a filename that starts with either a or b. |
{a,b,c}\*.txt | Matches any file with a .txt extension and a filename that starts with a, b, or c. |
**
pattern matches any sequence of directories, including zero or more directories.
For example, the pattern **/*.txt
matches any file with a .txt
extension, regardless of how many directories it is nested in.
Negative matching: The !
character can be used to negate a pattern. For example, the pattern !*.txt
matches any file that does not have a .txt
extension.