linux shell中实现循环日期的实例代码
下面通过一段代码给大家介绍linux shell中实现循环日期,具体代码如下所示:
#!/usr/bin/env bash start_date="20180726" end_date="20180830" while [ "$start_date" -le "$end_date" ]; do stat_date=`date -d "$start_date" +%Y-%m-%d` echo $stat_date start_date=$(date -d "$start_date+1days" +%Y%m%d) done1
补充:LINUX SHELL遍历日期(指定输入两个日期)
LINUX SHELL遍历日期,昨天写一个让我删了,写的也太坑了,很简单的东西墨迹那么长一串尴尬羞愧不已!
#! /bin/bash first=$1 second=$2 while [ "$first" != "$second" ] do echo $first let first=`date -d "-1 days ago ${first}" +%Y%m%d` done
结果:
总结
相关推荐
tianhuak 2020-11-24
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
zhangjie 2020-11-11
步知道 2020-10-27
tufeiax 2020-09-03
85251846 2020-09-14
huha 2020-10-16
lianshaohua 2020-09-23
laisean 2020-11-11
大牛牛 2020-10-30
firefaith 2020-10-30
liguojia 2020-10-20
wangzhaotongalex 2020-10-20
CARBON 2020-10-20
lianshaohua 2020-10-20