shell根据时间遍历处理
#! /bin/sh test.sh
date=`date -d "+0 day $1" +%Y%m%d`
enddate=`date -d "+1 day $2" +%Y%m%d`
echo "------------------------------"
echo "date=$date"
echo "enddate=$enddate"
echo "------------------------------"
while [[ $date < $enddate ]]
do
echo $date
date=`date -d "+1 day $date" +%Y%m%d`
done
执行:./test.sh 20140601 20140606