7. Brace Expansion

Brace expansion is done for characters within curly braces: {...}. Braced expressions generate lists of words. Ranges are declared by "start..end":

$ echo {01..10}
01 02 03 04 05 06 07 08 09 10

The step width can be increased by appending the step-width operator "..width" to the range:

$ echo {a..z..2}
a c e g i k m o q s u w y

An enumeration of words is separated by the "," operator:

$ echo {A,Clockwork,Orange}
A Clockwork Orange

A sequence of braced expressions is expanded like a Cartesian product. This means: Each expanded word from any braced expression is combined with any word expanded from any other braced expression:

echo {a..c}{1..3}
a1 a2 a3 b1 b2 b3 c1 c2 c3

A sub tree of hundreds of directories can be created by brace expansion easily:

$ mkdir -pv /home/pa/{foo,bar,baz}/{a..z..2}/{01..10}

Brace expansion is nestable and the evaluation starts with the innermost expression:

echo {a{1{i,j},2,3}}
a1i a1j a2 a3