From Wikipedia:
In computer programming, glob (/ɡlɑːb/) patterns specify sets of filenames with wildcard characters. For example, the Unix Bash shell command
mv *.txt textfiles/
moves (mv
) all files with names ending in.txt
from the current directory to the directorytextfiles
. Here,*
is a wildcard standing for "any string of characters except /" and*.txt
is a glob pattern. The other common wildcard is the question mark (?
), which stands for one character. For example,mv ?.txt shorttextfiles/
will move all files named with a single character followed by.txt
from the current directory to directoryshorttextfiles
, while??.txt
would match all files whose name consists of 2 characters followed by.txt
.In addition to matching filenames, globs are also used widely for matching arbitrary strings (wildcard matching). In this capacity a common interface is
fnmatch
.
In addition to matching filenames, globs are also used widely for matching arbitrary strings (wildcard matching). In this capacity a common interface is fnmatch.