4

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.

Community
  • 1
  • 1
Daniel
  • 617
  • 1
  • 7
  • 10

1 Answers1

7
mkdir -p backup.{0..7}
unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677