#! /bin/bash
first=$1
second=$2
while [ "$first" != "$second" ]
do
#echo $first
let first=`date -d "-1 days ago ${first}" +%Y%m%d`
echo `date -d "${first}" +%Y-%m-%d`
done
假设将上述的内容放到名为test.sh的脚本中,在linux系统中启动脚本命令:
sh test.sh 20180601 20180608
输出内容为:
2018-06-01
2018-06-02
2018-06-03
2018-06-04
2018-06-05
2018-06-06
2018-06-07
日期包含开始日期,不包含结束日期。