Bash script directory detection and creation

bash, scripting

Solution

mkdir -p backup.{0..7}

Problem

I have a bash script that depends on a group of folders existing, but dont want to create the folders by hand every time I use the script on a new machine. Right now I have the following for directory detection and creation (taken from here): ``` for i in {7..0} do if [ ! -d "backup.${i}" ]; then mkdir backup.${i} fi done ``` This detects and creates the folders 'backup.0' through 'backup.7' just fine, but there has to be a more elegant way to do this.

Original source

Related problems