1 1 3.5.8 Filename Expansion 1 ------------------------ 1
1 · Pattern Matching How the shell matches patterns. 1 11 After word splitting, unless the '-f' option has been set (⇒The Set Builtin), Bash scans each word for the characters '*', '?', and '['. 1 If one of these characters appears, then the word is regarded as a 1 PATTERN, and replaced with an alphabetically sorted list of filenames 1 matching the pattern (⇒Pattern Matching). If no matching 1 filenames are found, and the shell option 'nullglob' is disabled, the 1 word is left unchanged. If the 'nullglob' option is set, and no matches 1 are found, the word is removed. If the 'failglob' shell option is set, 1 and no matches are found, an error message is printed and the command is 1 not executed. If the shell option 'nocaseglob' is enabled, the match is 1 performed without regard to the case of alphabetic characters. 1 1 When a pattern is used for filename expansion, the character '.' at 1 the start of a filename or immediately following a slash must be matched 1 explicitly, unless the shell option 'dotglob' is set. When matching a 1 filename, the slash character must always be matched explicitly. In 1 other cases, the '.' character is not treated specially. 1 1 See the description of 'shopt' in ⇒The Shopt Builtin, for a 1 description of the 'nocaseglob', 'nullglob', 'failglob', and 'dotglob' 1 options. 1 1 The 'GLOBIGNORE' shell variable may be used to restrict the set of 1 filenames matching a pattern. If 'GLOBIGNORE' is set, each matching 1 filename that also matches one of the patterns in 'GLOBIGNORE' is 1 removed from the list of matches. If the 'nocaseglob' option is set, 1 the matching against the patterns in 'GLOBIGNORE' is performed without 1 regard to case. The filenames '.' and '..' are always ignored when 1 'GLOBIGNORE' is set and not null. However, setting 'GLOBIGNORE' to a 1 non-null value has the effect of enabling the 'dotglob' shell option, so 1 all other filenames beginning with a '.' will match. To get the old 1 behavior of ignoring filenames beginning with a '.', make '.*' one of 1 the patterns in 'GLOBIGNORE'. The 'dotglob' option is disabled when 1 'GLOBIGNORE' is unset. 1