#!/bin/bash usage() { printf "%s\n" \ "generate YYYY-MM-DD dates for a range" \ "usage: $(basename ${0}) -s -e " 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