Last active
December 26, 2015 08:19
-
-
Save siwells/7121994 to your computer and use it in GitHub Desktop.
Shell script for Bash on OS X to generate a range of dates given a start date and an end date in the YYYY-MM-DD format.
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 | |
| currentDateTs=$(date -j -f "%Y-%m-%d" $1 "+%s") | |
| endDateTs=$(date -j -f "%Y-%m-%d" $2 "+%s") | |
| offset=86400 | |
| while [ "$currentDateTs" -le "$endDateTs" ] | |
| do | |
| date=$(date -j -f "%s" $currentDateTs "+%Y-%m-%d") | |
| echo $date | |
| currentDateTs=$(($currentDateTs+$offset)) | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment