I have catalogs
site_2021-11-09_0
site_2021-11-09_1
site_2021-11-09_2
site_2021-11-09_3
site_2021-11-09_4
site_2021-11-09_5
site_2021-11-09_6
I need to add next directory that does not exist, which is site_2021-11-09_7. I need to write a script on loops. How can this be done?
I currently have
#!/bin/bash
date="$(date +%F)"
site="site"
i="0"
while [ ! -d ${site}_${date}_$i ]
do
echo ${site}_${date}_$i
mkdir ${site}_${date}_$i
i=$(( $i + 1))
done
but it doesn't work. If no directories exist, it works forever. If there is directory site_2021-11-09_0, it doesn't work at all. How to understand it logically?