globbing
The step where bash replaces a word containing a star, a question mark or square brackets with the sorted list of file names that match it.
In more detail
The command never sees the pattern, only the matching names. If nothing matches, bash leaves the pattern as it is by default. It also applies to unquoted variables, so a star stored in a variable turns into file names unless quoted.
Related terms
- glob pattern — A pattern that matches names using * for any run of characters, a question mark for one character and [abc] for one of a set.
- globstar — A bash 4 option that makes a double star in a glob match files at any depth of subdirectories.
- word splitting — The step where bash cuts the result of an unquoted expansion into separate words at spaces, tabs and newlines.
- double quotes — Quotes that keep text together as one word but still let dollar expansions and backticks work inside.
Taught in
- What Bash Does To A Line Before It Runs It — Bash Scripting & Command Line Automation
- Single Quotes, Double Quotes, Backslash — Bash Scripting & Command Line Automation
- The Unquoted Variable: Splitting And Globbing — Bash Scripting & Command Line Automation
- Conditionals: test, Brackets, Double Brackets, case — Bash Scripting & Command Line Automation
- Loops: for, while, until, break, continue — Bash Scripting & Command Line Automation
- ShellCheck — Bash Scripting & Command Line Automation
- Style That Prevents Bugs — Bash Scripting & Command Line Automation