Linux date
begin="2016-01-01" for (( i = 0; i < 21; i++ )); do current=$(date -d "$i day $begin" +"%Y-%m-%d") echo $current done
mac date
begin="2016-01-01"
begin=`date -j -f %Y-%m-%d $begin +%s`
for (( i = 0; i < 21; i++ )); do current=`date -r $(expr $begin + $i \* 86400) +"%Y-%m-%d"` echo $current done
mac的实现相对复杂一点,不理解的请看我的