简体   繁体   English

Shell脚本中的日期比较

[英]Date comparison in shell script

In my script to monitor expiry date of .der certificates, I managed to take out the expiry date of the certificate but when I compare with the current date, its not happening. 在监视.der证书的到期日期的脚本中,我设法取出了证书的到期日期,但是当与当前日期比较时,它没有发生。 The expiry date has m/d/yy format, I compared that with current date of the same format(mm/dd/yy) its failing. 到期日期具有m / d / yy格式,我将其与相同格式(mm / dd / yy)的当前日期进行比较。 When I grep the expiry date, is the result has the same date format or it changes to string? 当我grep到期日期时,结果是否具有相同的日期格式或更改为字符串? Can you please help me with this? 你能帮我吗?

d=7/7/11
dd=$(IFS=/; printf "%02d/%02d/%02d" $d)
echo $dd  # => 07/07/11

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM