Bash script detection and directory creation

I have a bash script that depends on a group of existing folders, but I don't need to create folders manually every time I use the script on a new computer.

Now I have the following for detecting and creating directories (taken from here ):

for i in {7..0} do if [ ! -d "backup.${i}" ]; then mkdir backup.${i} fi done 

This detects and backs up folders using "backup.0" through "backup.7", but this should be a more elegant way to do this.

+4
source share
1 answer
 mkdir -p backup.{0..7} 
+7
source

Source: https://habr.com/ru/post/1302154/


All Articles