Using the ISO 8601 date format (year-month-day), you can compare dates lexicographically. This is a bit messier than we would like, since bash does not have a "<=" operator for strings.
year=2011 d="$year-01-01" last="$(($year+1))-01-01" while [[ $d < $last ]]; do echo $d d=$(date +%F --date "$d + 1 day") done
chepner
source share