*** Welcome to piglix ***

Glob (programming)


In computer programming, in particular in a Unix-like environment, glob patterns specify sets of filenames with wildcard characters. For example, the Unix command mv *.txt textfiles/ moves (mv) 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" and *.txt is a glob pattern. The other common wildcard is the question mark (?), which stands for one character.

The command interpreters of the early versions of Unix (1st through 6th Editions, 1969–75) relied on a separate program to expand wildcard characters in unquoted arguments to a command: /etc/glob. That program performed the expansion and supplied the expanded list of file paths to the command for execution. Its name is an abbreviation for "global command". Later, this functionality was provided as a library function, glob(), used by programs such as the shell.

The most common wildcards are *, ?, and […].

In all cases the path separator character (/ on unix or \ on windows) will never be matched.

On Linux and POSIX systems *, ? is defined as above while […] has two additional meanings:

Some shells (such as the C shell and Bash) support additional syntax known as alternation or brace expansion.

The Bash shell also supports Extended Globbing which allows other pattern matching operators to be used to match multiple occurrences of a pattern enclosed in parentheses. It can be enabled by setting the extglob shell option.


...
Wikipedia

...