cd $(dirname $0)
nowdate=$1
if [ $# -eq 0 ];then
echo "not input initparam"
else
if [ "$nowdate" = "0" ];then
nowdate=`date +%Y%m01` #本月第一天
startdate=`date -d"$nowdate last month" +%Y%m%d` #上个月第一天
enddate=`date -d"$nowdate last day" +%Y%m%d` #上个月最后一天
else
startdate=`date -d"$nowdate last month" +%Y%m%d` #上个月第一天
enddate=`date -d"$nowdate last day" +%Y%m%d` #上个月最后一天
fi
#遍历上个月的每一天
while (( $startdate <= $enddate ))
do
var="$startdate"
echo $startdate
startdate=`date -d "+1 day $startdate" +%Y%m%d`
done
fi