Skip to content
The Bash Insectarium

/static/insetario/en/inseto/chaves-prefixo/

Menu

BSH-003 · Braces

dir/{a,b,c}

Nested braces and a shared prefix: a directory tree in one line.

Whatever sits outside the braces is stitched onto every result: projeto/{src,doc,test} yields three paths with the same trunk. With mkdir -p, the whole tree springs up in one stroke.

Braces nest: {a,b{1,2}} becomes a b1 b2. You can sketch entire structures — projeto/{src/{nucleo,util},doc} — before the first file exists.

$ mkdir -p projeto/{src,doc,test}
$ ls projeto
doc  src  test
$ echo ninho/{ovos,larvas{1,2}}
ninho/ovos ninho/larvas1 ninho/larvas2
The whole tree, planted in a single line.