遍历日期
指定两个日期,循环输出所有日期:
#! /bin/bash
first=$1
second=$2
while [ "$first" != "$second" ]
do
echo $first
first=`date -d "-1 days ago ${first}" +%Y%m%d`
done
例子:
sh test2.sh 20200303 20200310
20200303
20200304
20200305
20200306
20200307
20200308
20200309
获取某个日期 N 天前的日期
date -d "20200311 1 days ago " "+%Y%m%d"
网友评论