#!/bin/bash # # Bash script to print list of dates from starting date to ending date # Written by Arul John # Blog Post: https://aruljohn.com/blog/bash-sequence-of-dates/ # # Accept arguments -- start date and end date if [[ $# -lt 2 ]] ; then echo "USAGE: $0 " exit 0 fi # Get start date and end date and convert both to their epoch dates start_date=$(date --date "$1" +%s) end_date=$(date --date "$2" +%s) # Loop through both dates and print all dates in between while [[ "$start_date" -le "$end_date" ]]; do current_date="$(date -d "$(date -d @$start_date)" -I)" echo "$current_date" start_date=$((start_date + 86400)) done