If you're dealing with shell scripts and traversing a time frame is a common thing, let's share with you today:
#!/usr/bin/env bashdate1= "$" date2= "$" echo "Date1: $date 1" echo "Date2: $date 2" tempdate= ' date-d "-0 day $date 1" +%f " Enddate= ' date-d '-0 day $date 2 "+%f ' tempdatesec= ' date-d"-0 day $date 1 "+%s ' enddatesec= ' date-d"-0 day $date 2 "+%s ' echo "####################################" Echo ' tempdate: ' $tempdateecho ' enddate: ' $enddate #for i in ' seq 1 130 '; Dofor i in ' SEQ 1 300 '; Do if [[$tempdateSec-lt $enddateSec]] and then break fi echo $tempdate python pc_jibzhuanti_url.py $tempdate tempdate= ' date-d '-$i day $date 1 "+%f ' tempdatesec= ' date-d"-$i day $date 1 "+%s" done
This is a reverse output time script, you need to enter two time parameters, one is the start time, one is the end time, such as input:
./pc_jibzhuanti_url_run.sh 2014-06-30 2014-06-01
The result of the output is:
Date1:2014-06-30
Date2:2014-06-01
####################################
Tempdate:2014-06-30
Enddate:2014-06-01
2014-06-30
2014-06-29
2014-06-28
2014-06-27
2014-06-26
2014-06-25
2014-06-24
2014-06-23
2014-06-22
2014-06-21
2014-06-20
2014-06-19
2014-06-18
2014-06-17
2014-06-16
2014-06-15
2014-06-14
2014-06-13
2014-06-12
2014-06-11
2014-06-10
2014-06-09
2014-06-08
2014-06-07
2014-06-06
2014-06-05
2014-06-04
2014-06-03
2014-06-02
2014-06-01
OK, done!!!
Shell traversal of a date range