#!/bin/bash
# display all dates between arg1 and arg2
date1=$1
date2=$2
# checks dates
if ! date -d "$date1" 2>&1 > /dev/null ;
then echo "first date is invalid" ; exit 1
fi
if ! date -d "$date2" 2>&1 > /dev/null ;
then echo "second date is invalid" ; exit 1
fi
#set current and end date
current=$(date -d "$date1" +%F)
end=$(date -d "$date2" +%F)
#loop over all dates
while [ "$end" != "$current" ]
do
echo $current
current=$(date -d "$current +1 days" +%F)
done
echo $current