How does glob pattern matching work in Unix?

How does glob pattern matching work in Unix?

The Unix name for wildcard pattern matching is GLOBbing, from the idea that the pattern matches a “global” list of names. Other operating systems may call these wildcard characters. GLOB patterns do not only match file names. The names being matched by a GLOB pattern can be anything: files, directories, symbolic links, etc.

Can a glob pattern match a three character name?

The GLOB pattern [abc] does not match the three-character name abc; it matches only the one-character names a, or b, or c: No matter how many characters are in the list, a [list] pattern will only match exactly one of the characters in the list, not more than one, not less.

How are odd glob patterns different from regular globs?

The GLOB patterns [aA] and [a] [A] are very different: 1 The GLOB pattern [aA] is one list, so it matches only one-character names. It matches any one character from the list… 2 The odd GLOB pattern [a] [A] is made up of two lists, so it matches only two-character names. It matches only the… More

Can a glob match the leading period of a hidden name?

GLOB metacharacters never match the leading period on any hidden names, so you don’t have to worry about matching the names . or .. accidentally. As a GLOB metacharacter, the asterisk * matches zero or more of any character in a name, including spaces or other strange characters.

Can a glob pattern generate characters that do not exist?

GLOB patterns cannot generate any names that do not exist. The GLOB patterns must always match existing names. Characters that the shell will try to expand to match existing pathnames in the file system. These characters are sometimes called “wildcard” characters in other systems.

Can a glob pattern match both upper and lower case letters?

Normally, GLOB patterns are case-sensitive so that abc* does not match any of the names ABC, aBc, Abc, etc. If you want to match both upper- and lower-case letters in names, make each letter into its own little two-character [] list so that the list matches either upper- or lower-case: