Created
March 22, 2019 05:57
-
-
Save hardiksondagar/6e433bae8a0cb12498a2413b269fb72e to your computer and use it in GitHub Desktop.
Looping through dates in shell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -l | |
# loop-dates.sh 2019-02-01 2019-03-01 | |
start_time=`date +"%Y-%m-%d" -d $1` | |
end_time=`date +"%Y-%m-%d" -d $2` | |
dt=$start_time | |
while [ "$dt" != "$end_time" ] ; | |
do | |
start=`date '+%Y-%m-%d %T' -d "$dt"`; | |
end=`date '+%Y-%m-%d %T' -d "$dt +1 day"`; | |
echo $start, $end | |
python your-awesome-script.py --start_time="$start" --end_time="$end" | |
dt=`date +"%Y-%m-%d" -d "$dt +1 day"`; | |
sleep 1s | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment