我试图做一个简单的for {}循环,我遇到了在循环内部分配变量的问题。我将尝试在示例中解释它:
DIFF=(`date +%s -d 20120203`-`date +%s -d 20120126`)/86400 # Difference between 2 dates.
echo $DIFF
end_date_change='20120126'
for i in {1..$DIFF} #Difference between 2 dates inside loop
do
end_date_change=$(end_date_change -d "-1 day") # Now, after every loop I would like to decrease date
echo $end_date_change
done
所以输出应该是:
20120126
20120127
20120128
20120201
20120202
20120203
任何?提前致谢