Skip to content

Instantly share code, notes, and snippets.

@shirish87
Created August 19, 2019 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirish87/885c74d6b4c119e8ae237ff4f5c214a8 to your computer and use it in GitHub Desktop.
Save shirish87/885c74d6b4c119e8ae237ff4f5c214a8 to your computer and use it in GitHub Desktop.
#!/bin/bash
# https://stackoverflow.com/questions/28226229/bash-looping-through-dates
startdate=$(date -I -d "$1") || exit -1
enddate=$(date -I -d "$2") || $(date -I)
d="$startdate"
while [ "$(date -d "$d" +%Y%m%d)" -le "$(date -d "$enddate" +%Y%m%d)" ]; do
echo "$d"
d=$(date -I -d "$d + 1 day")
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment