shell生成連續天數日期


 

#!/bin/bash
#兩個參數:起始時間和終止時間,循環輸出每天
#輸入格式:20171201 20171225
#輸出格式:2017-12-01 2017-12-25
startdate=`date -d "+0 day $1" +%Y%m%d`
enddate=`date -d "+0 day $2" +%Y%m%d`

while [[ $startdate -le $enddate ]]
do
date=$startdate
startdateother=`date -d "+0 day $date" +%Y-%m-%d`
dateother=$startdateother
echo "$dateother"
startdate=`date -d "+1 day $date" +%Y%m%d`
startdateother=`date -d "+1 day $date" +%Y-%m-%d`
# write code here
echo /usr/bin/python /home/admin/bin/getappidasrandtts.py /data/trace/trace.log.$dateother /data/trace/appidasrtts.log.$dateother
/usr/bin/python /home/admin/bin/getappidasrandtts.py /data/trace/trace.log.$dateother /data/trace/appidasrtts.log.$dateother
done

 

備份備查


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM