In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to implement Shell script traversal of a date range", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's take you to learn "how to implement Shell script traversal of a date range"!
The code is as follows:
#!/ 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
This is a script that outputs time in reverse order. You need to input two time parameters, one is the start time and the other is the end time. For example, input:
The code is as follows:
./ pc_jibzhuanti_url_run.sh 2014-06-30 2014-06-01
The output is:
The code is as follows:
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
At this point, I believe that everyone has a deeper understanding of "how to implement Shell script traversal of a date range," may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.