9 views

1 Answers

In computer programming, glob patterns specify sets of filenames with wildcard characters. For example, the Unix Bash shell command mv *.txt textfiles/ moves all files with names ending in.txt from the current directory to the directory textfiles. 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 directory shorttextfiles, 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. In this capacity a common interface is fnmatch.

9 views