天等多種用法"/>
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 前一天等多種用法
发布评论