function date_gen(){ [[ $1 ]] || exit 1; [[ $2 ]] || exit 2; (( $(date -d "$1" +'%s') < $(date -d "$2" +'%s') )) || exit 3; fmt='%Y_%m_%d'; ct=0; target_day=$(date -d"$2" +"$fmt"); while curr_day=$(date -d"$1 +$ct day" +"$fmt") [ "$curr_day" != "$target_day" ] do echo $curr_day; ct=$((ct + 1)); done } days=$(date_gen "2012/12/12" "2012/12/19");