惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Security Archives - TechRepublic
MongoDB | Blog
MongoDB | Blog
量子位
博客园 - 叶小钗
罗磊的独立博客
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News: Ask HN
Hacker News: Ask HN
MyScale Blog
MyScale Blog
GbyAI
GbyAI
Help Net Security
Help Net Security
Y
Y Combinator Blog
Engineering at Meta
Engineering at Meta
Hacker News - Newest:
Hacker News - Newest: "LLM"
Latest news
Latest news
H
Hacker News: Front Page
Blog — PlanetScale
Blog — PlanetScale
雷峰网
雷峰网
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
S
Schneier on Security
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
S
Security @ Cisco Blogs
Recorded Future
Recorded Future
S
Securelist
博客园 - Franky
Application and Cybersecurity Blog
Application and Cybersecurity Blog
A
About on SuperTechFans
N
News and Events Feed by Topic
AI
AI
T
Tenable Blog
N
News | PayPal Newsroom
C
Cybersecurity and Infrastructure Security Agency CISA
V
V2EX - 技术
T
Threat Research - Cisco Blogs
Cisco Talos Blog
Cisco Talos Blog
L
LINUX DO - 热门话题
N
Netflix TechBlog - Medium
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google Online Security Blog
Google Online Security Blog
S
Security Affairs
Webroot Blog
Webroot Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 三生石上(FineUI控件)
C
Comments on: Blog
G
GRAHAM CLULEY

博客园 - 王晓成

Spark RDD 操作 (转)Mysql哪些字段适合建立索引 Specified key was too long; max key length is 767 bytes解决方案 (转)并发编程 – Concurrent 用户指南 - 王晓成 协同过滤 (转)K-近邻算法(KNN) 贝叶斯、朴素贝叶斯及调用spark官网 mllib NavieBayes示例 决策树之ID3,C4.5及CART kmeans Spark下的FP-Growth和Apriori scala spark-streaming整合kafka (spark 2.3 kafka 0.10) (转)Java 详解 JVM 工作原理和流程 Scala map与flatMap php 正则表达式 (转发)storm 入门原理介绍 shell :将标准输出及标准错误输出写到指定文件 MongoDB基本操作 (转)cenntos 安装mongodb 通过spark sql 将 hdfs上文件导入到mongodb
shell循环(两个日期比较,改变某个特定日期来改变当前比较值)
王晓成 · 2018-07-23 · via 博客园 - 王晓成

需求:从当前时间前6个月开始执行某个语句,直到执行到当前日期的前一天。 

 shell脚本如下:

#!/bin/bash

yesterday=`date -d -1day +%Y%m%d`

sixmonthsago=` date -d -6month +%Y%m%d` 

echo $sixmonthsago

while [[ $sixmonthsago < $yesterday  ]]

do

         curDate=`date -d "+0 day $sixmonthsago" +%Y-%m-%d`         

          echo curDate  

        sixmonthsago=`date -d "+1 day $sixmonthsago" +%Y%m%d`

        echo $sixmonthsago

done

注意: sixmonthsago=`date -d "+1 day $sixmonthsago" +%Y%m%d`这个写法,在If条件语句下此写法不好用。

测试结果:

[root@master shell]# sh t.sh 

20180123

20180124

20180125

20180126

20180127

20180128

20180129

20180130

20180131

20180201

20180202

20180203

。。。

20180719

20180720

20180721

20180722

[root@master shell]#