shell获取日期

来源:互联网 发布:网络营业执照 编辑:程序博客网 时间:2024/06/10 00:02
[root@localhost testshell]# date +%Y%m%d 
20150528
[root@localhost testshell]# date +%F 
2015-05-28
[root@localhost testshell]# date +%y%m%d 
150528


[root@localhost testshell]# date -d -1day +%Y%m%d
20150527
[root@localhost testshell]# date -d -1day +%y%m%d
150527
[root@localhost testshell]# date -d yesterday +%Y%m%d
20150527
[root@localhost testshell]# date -d yesterday +%y%m%d
150527


获取n天前的 `date -d "n days ago" +%y%m%d` 


0 0