如何计算 touch -t 的日期

Per*_*kie 5 command-line time touch-command

如何在bash中创建日期类型?

这个日期是什么意思?'1803141400'

touch -t 1803141400 test1 test2
Run Code Online (Sandbox Code Playgroud)

如何计算时间?

Let*_*ety 6

根据触摸手册页

  -t STAMP
              use [[CC]YY]MMDDhhmm[.ss] instead of current time
Run Code Online (Sandbox Code Playgroud)

在哪里:

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
Run Code Online (Sandbox Code Playgroud)

[] 表示该字段是可选的

在您的示例中1803141400意味着:2018 mar 14, 14.00并将根据此值touch更改test1test2文件的时间戳。

$ 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
Run Code Online (Sandbox Code Playgroud)