#!/bin/sh source ~/.bash_profile; source /etc/profile; start_date="20190622" end_date="20190625" while [ "$start_date" -le "$end_date" ]; do yestertoday=`date -d "$start_date" +%Y-%m-%d` today=`date -d "$start_date+1days" +%Y-%m-%d` echo "yestertoday is $yestertoday today is $today" start_date=`date -d "$start_date+1days" +%Y%m%d` done
原文:https://www.cnblogs.com/kai-xuan/p/15007749.html