码迷,mamicode.com
首页 > 系统相关 > 详细

linux

时间:2018-06-22 13:41:16      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:star   linux   class   for   done   highlight   pre   tar   展示   

# 这里的例子每天作为循环,并展示当天的前一天
#!/bin/bash

startDate=20160201
endDate=20160328
startSec=`date -d "$startDate" "+%s"`
endSec=`date -d "$endDate" "+%s"`
for((i=$startSec;i<=$endSec;i+=86400))
do
    current_day=`date -d "@$i" "+%Y%m%d"`
    one_day_ago=`date -d "$current_day yesterday" +%Y%m%d`
    echo "current_day:${current_day}, yesterday:${one_day_ago}"
done

  

linux

标签:star   linux   class   for   done   highlight   pre   tar   展示   

原文地址:https://www.cnblogs.com/zhangyanhe/p/9212449.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!