The for loop does not work if I use the $DAYSDIFF variable but it does work if I type in the number of days since 2020-01-21. When I use $DAYSDIFF, I get an error date: invalid date ‘2020-01-21 + {0..97} day’
Is there a way to use the calculated number of days variable in the "IN" clause of the loop? I'm using Ubuntu 18.04.
REPDATE=2020-01-21 #Date of first COVID-19 report.
CURDATE=`date "+%Y%m%d"` #Todays date.
DAYSDIFF=$(( (`date -d $CURDATE +%s` - `date -d $REPDATE +%s`) / (24*3600) ))
#echo $DAYSDIFF #The correct number of days is echoed.
REPORTNUM=1
for i in {0..$DAYSDIFF} #DAYSDIFF is not working. If I type a number here it works.
do
NEXT_DATE=$(date +%Y%m%d -d "$REPDATE + $i day")
echo wget https://www.who.int/docs/default-source/coronaviruse/situation-reports/"$NEXT_DATE"-sitrep-"$REPORTNUM"-covid-19.pdf
#wget https://www.who.int/docs/default-source/coronaviruse/situation-reports/"$NEXT_DATE"-sitrep-"$REPORTNUM"-covid-19.pdf
REPORTNUM=`expr $REPORTNUM + 1`
done