Brace expansion in Bash
The shell generates strings before anything runs.
# brace expansion builds strings before anything runs
echo file_{a,b,c}.txt
echo {1..5}
echo {01..10..3}
# it combines: a tiny cartesian product
echo {dev,prod}-{web,db}
# and pairs with cp-style renames in real use
echo cp config{.yaml,.yaml.bak}
How it works
{a,b,c}multiplies against whatever surrounds it.{1..5}and{01..10..3}count, pad and step.- Two braces make a product;
config{.yaml,.yaml.bak}is the rename idiom.
Keywords and builtins used here
echo
The run, in numbers
- Lines
- 10
- Characters to type
- 249
- Tokens
- 33
- Three-star pace
- 85 tpm
At the three-star pace of 85 tokens a minute, this run takes about 23 seconds.
Step 3 of 3 in Loops, step 9 of 26 in Language basics.