如何在bash中创建日期类型?
这个日期是什么意思?'1803141400'
这个日期是什么意思?'1803141400'
touch -t 1803141400 test1 test2
我该如何计算时间?
touch -t 1803141400 test1 test2
我该如何计算时间?
-t STAMP
use [[CC]YY]MMDDhhmm[.ss] instead of current time
其中:
CC: First two digit of the year
YY: Last two digits of the year
MM: Month (two-digit numeric month)
DD: Day (two-digit numeric day i.e. day of month)
hh: Hour
mm: Minutes
ss: Seconds
[]
表示该字段是可选的
在你的例子中,1803141400
的意思是:2018年3月14日,14点00分
,而 touch
将根据这个值来更改 test1
和 test2
文件的时间戳。
$ ls -l test1 test2
-rw-rw-r-- 1 yourUser yourGroup 0 mar 14 2018 test1
-rw-rw-r-- 1 yourUser yourGroup 0 mar 14 2018 test2
[guru@guru-Aspire ~]$touch -t 12141105 temp
[guru@guru-Aspire ~]$ls -l --full-time temp
-rw-rw-r-- 1 guru guru 0 2014-12-14 11:05:00.000000000 +0530 temp
CC
和YY
,它会自动插入当前的CC和YY。touch -t 1803141400 test1 test2
,[guru@guru-Aspire ~]$ ls -l --full-time test*
-rw-rw-r-- 1 guru guru 0 2018-03-14 14:00:00.000000000 +0530 test1
-rw-rw-r-- 1 guru guru 0 2018-03-14 14:00:00.000000000 +0530 test2