According to wikipedia, glob patterns specify sets of filenames with wild card characters.
But what the heck is a wild card character ?
Again according to wikipedia, a wild card character is a character that can be
used to substitute for any other character or characters in a string. For
example in regex,
. matches any character, and so
. is a wild card character
Actually speaking about regex, as you might know
.* is used to match any
number of arbitrary characters, which may be different, since
. stands for match any character and
* stands for match any number of the preceding character.
* in this context, has a special name, Kleene Star.
So we know what is a wild card character, we know what is a regex (regular expression), now coming back to the first definition on this page:
A Glob Pattern specifies sets of filenames with wild card characters.
Examples of Glob Patterns in shell are:
One important thing to note is that globs do not include the syntax for the Kleene star.
|Wildcard in Glob||Equivalent Regex|
So say, for some reason, you are in a directory which has only markdown files,
and you want to list all files that have numeric names like
1234.md. In regex
you could simply do
[0-9]+.md, but you can’t do that in globs
Notably, glob patterns are also used in git. You might use them frequently when
you are specifying a
.gitignore file for your project.