2022-12-01

Brace expansion

Brace expansion on Wiki

Tweet from Wes Bos

Examples

❯ echo {1,2,3} 1 2 3
# Spaces are not allowed echo {1, 2, 3} zsh: parse error near `}'
❯ echo file{1,2,3} file1 file2 file3
❯ echo file{,2,3} file file2 file3
❯ echo file{1..3} file1 file2 file3
❯ echo file{001..3} file001 file002 file003
❯ mkdir -p settings/{__init__,base,local} ❯ tree . └── settings ├── __init__ ├── base └── local
❯ touch 11.{in,py} ❯ tree . ├── 11.in └── 11.py
❯ touch post_2022_{01..3}.md ❯ tree . ├── post_2022_01.md ├── post_2022_02.md └── post_2022-03.md
❯ touch test.js ❯ cp test{,_copy}.js ❯ tree . ├── test.js └── test_copy.js
❯ touch test.txt ❯ mv test.{txt,md} ❯ tree . └── test.md