利用date 指令來取得,格式如下
date "+%Y %m %d %H:%M:%S"
date "+%Y %m %d %H:%M:%S"
Display the current time in the given FORMAT, or set the system date.
-d, --date=STRING
display time described by STRING, not `now'
%Y year (1970...)
%m month (01..12)
%d day of month (01..31)
%H hour (00..23)
%M minute (00..59)
%S second (00..60); the 60 is necessary to accommodate a leap second
當天
date +%Y%m%d
前一天# date --date='1 days ago' +%Y%m%d
# date -d '1 days ago' +%Y%m%d
# date -d yesterday +%Y%m%d
明天
# date --date='1 days' +%Y%m%d
# date -d '1 days' +%Y%m%d
# date -d tomorrow +%Y%m%d