Created
January 20, 2017 18:15
-
-
Save kyleparisi/7a9d1bb766b2696e7d4f9b3521f2995d to your computer and use it in GitHub Desktop.
Bash script that loops over dates for other atomic scripts
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 | |
# On linux use date, on mac gdate [via `brew install coreutils`]. | |
# Will run from oldest date to today. | |
# $ sh date_looper.sh '2016-12-10' | |
currentdate=$1 | |
loopenddate=$(gdate --date "$2 1 day" +%Y-%m-%d) | |
until [ "$currentdate" == "$loopenddate" ] | |
do | |
echo $currentdate | |
# SOME_COMMAND_THAT_ACCEPTS_A_DAY $currentdate | |
# update current date to next day | |
currentdate=$(gdate --date "$currentdate 1 day" +%Y-%m-%d) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment