brace expansion
The first expansion, which turns a pattern like {a,b} or {1..3} into several words, whether or not matching files exist.
In more detail
file.{txt,md} becomes file.txt file.md, and {1..5} counts from 1 to 5. Unlike globbing it does not look at the disk at all. It is a bash feature, not POSIX, and variables inside the braces are not expanded in time for it to use them.
Examples
mkdir -p notes/{drafts,archive}echo {1..3}Related terms
- shell expansion — The rewriting bash does to a command line before running it, replacing variables, patterns and other special forms with their values.
- 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.
Taught in
- What Bash Does To A Line Before It Runs It — Bash Scripting & Command Line Automation
- Finding Lines: grep And Regular Expressions — Bash Scripting & Command Line Automation
- Reshaping Text: cut, sort, uniq, tr, sed, awk — Bash Scripting & Command Line Automation
- Parameter Expansion: Defaults, Length, Slices — Bash Scripting & Command Line Automation