Bash script directory detection and creation

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.


mkdir -p backup.{0..7}
链接地址: http://www.djcxy.com/p/17496.html

上一篇: BASH中的基本shell脚本

下一篇: Bash脚本目录检测和创建