diff options
-rwxr-xr-x | generate-dates.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/generate-dates.sh b/generate-dates.sh new file mode 100755 index 0000000..ee3796e --- /dev/null +++ b/generate-dates.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +usage() { + printf "%s\n" \ + "generate YYYY-MM-DD dates for a range" \ + "usage: $(basename ${0}) -s <start YYYY-MM-DD> -e <end YYYY-MM-DD>" + exit 1 +} + +while getopts "s:e:h" opts; do + case "${opts}" in + s) start="${OPTARG}";; + e) end="${OPTARG}";; + h) usage;; + *) usage;; + esac +done + +if test "${start}" && test "${end}"; then + current="${start}" + + while [[ "$current" < "$end" || "$current" == "$end" ]]; do + printf "%s\n" "${current}" + current=$(date -I -d "${current} + 1 day") + done +else + usage +fi + |