标签:blog for on 2014 log 时间 as python file
如果跟shell脚本打交道,遍历一个时间范围是很常见的事情,那么今天就跟大家分享一下:
#!/usr/bin/env bash date1="$1" date2="$2" echo "date1: $date1" echo "date2: $date2" tempdate=`date -d "-0 day $date1" +%F` enddate=`date -d "-0 day $date2" +%F` tempdateSec=`date -d "-0 day $date1" +%s` enddateSec=`date -d "-0 day $date2" +%s` echo "####################################" echo 'tempdate: '$tempdate echo 'enddate: '$enddate #for i in `seq 1 130`; do for i in `seq 1 300`; do if [[ $tempdateSec -lt $enddateSec ]]; then break fi echo $tempdate python pc_jibzhuanti_url.py $tempdate tempdate=`date -d "-$i day $date1" +%F` tempdateSec=`date -d "-$i day $date1" +%s` done
./pc_jibzhuanti_url_run.sh 2014-06-30 2014-06-01
输出的结果是:
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,搞定!!!!
标签:blog for on 2014 log 时间 as python file
原文地址:http://blog.csdn.net/liuhui_306/article/details/41478155