linux shell date 前一天,linux date 前一天等多種用法

编程入门 行业动态 更新时间:2024-10-24 07:28:56

linux shell date 前一天,linux date 前一<a href=https://www.elefans.com/category/jswz/34/1033145.html style=天等多種用法"/>

linux shell date 前一天,linux date 前一天等多種用法

source: 

BASH SHELL中可以定義變量顯示當前日期

顯示當前日期是

DATE=`date +%Y%m%d`  +號后面是定義格式為年月日

顯示前一天為

DATE1=`date -d '1 days ago' +%Y%m%d` 加-d參數可以設置與當前日期的計算時間,同樣,前2天為'2 days ago',去掉ago則為當前日期之后多少天

Here are a few examples. Also see the documentation for the `-d' option in the previous section.

To print the date of the day before yesterday:date --date='2 days ago'

To print the date of the day three months and one day hence:date --date='3 months 1 day'

To print the day of year of Christmas in the current year:date --date='25 Dec' +%j

To print the current full month name and the day of the month:date '+%B %d'But this may not be what you want because for the first nine days of the month, the `%d' expands

更多推荐

linux shell date 前一天,linux date 前一天等多種用法

本文发布于:2024-02-27 09:24:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1706028.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:天等   linux   shell   date

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!