brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: brace expansion builds a folder tree in one shell command

Shell
~/tips/tip-shell-brace-expansion-folder-tree

mkdir -p backup/{2025,2026}/{01..12}

Creates many folders at once by letting the shell expand braces.

Making twelve month folders by hand is the kind of job the shell does for you.

mkdir -p backup/{2025,2026}/{01..12}
ls backup/2026

The shell expands the braces before mkdir runs, producing every combination, 24 paths here. {01..12} counts with leading zeros in bash 4 and zsh. Use echo instead of mkdir first to preview the result. Braces do not expand inside quotes, and the list must have no spaces. Zsh and bash both do this, so the line works the same in either.

Further reading: Bash manual: Brace Expansion

More Shell tips zmv -n '(*).log' '$1.txt' zoxide query -ls project f=$(mktemp --suffix=.json) shopt globskipdots echo $EPOCHSECONDS All Shell tips (78) All topics

Link