bash shell —— while & date

StartDate=$(date --date="${dataset_date} -1 month" +%Y-%m-01)
EndDate=$(date -d "-$(date +%d) days" +%Y-%m-%d)

year=$(date --date="${dataset_date} -1 month" +%Y)
month=$(date --date="${dataset_date} -1 month" +%m)
echo "year=${year},month=${month}"

mindate=$(date -d '2020-01-01' +'%Y-%m-%d')
echo "Start to build dailyreport,StartDate=${StartDate},mindate=${mindate}"
t1=`date -d ${StartDate} +%s`
t2=`date -d ${mindate} +%s`

while [ $t1 -gt $t2 ]
do
  echo "Start to build dailyreport,StartDate=${StartDate},EndDate=${EndDate}"

  StartDate=$(date --date="${StartDate} -1 month" +%Y-%m-01)
  EndDate=$(date --date="${EndDate} -1 month"  +%Y-%m-%d)
  t1=`date -d ${StartDate} +%s`
done

  

posted @ 2022-04-19 15:34  PanPan003  阅读(27)  评论(0编辑  收藏  举报