shell 日期格式 2022-03-15

Posted 闭关苦炼内功

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell 日期格式 2022-03-15相关的知识,希望对你有一定的参考价值。

  • 前一天

date -d '-1 day' +%F

[test@localhost ~]$ date1=`date -d '-1 day' +%F`
[test@localhost ~]$ echo $date1
2022-03-14
[test@localhost ~]$
  • 今天

date +%F

[test@localhost ~]$ date2=`date +%F`
[test@localhost ~]$ echo $date2
2022-03-15
[test@localhost ~]$
  • 后一天

date -d '+1 day' +%F

[test@localhost ~]$ date3=`date -d '+1 day' +%F`
[test@localhost ~]$ echo $date3
2022-03-16
[test@localhost ~]$

以上是关于shell 日期格式 2022-03-15的主要内容,如果未能解决你的问题,请参考以下文章

Linux下Shell日期的格式

linuxlinux shell 日期格式化

shell日期格式和数字运算

shell脚本 - 日期比较与判断

Bash shell:如何从变量值重新格式化字符串日期

shell 中可以for 循环的时间加减日期格式