touch -a 隻更改存取時間
-d 使用指定的時間
-m 隻修改變動時間
touch -t 201810011003.17 file2
[[CC]YY]MMDDhhmm[.SS]
指令:
touch file1 file2
輸出:
hc@hc-virtual-machine:~/test

hc@hc-virtual-machine:~/test$ ll
總用量 8
drwxr-xr-x 2 hc hc 4096 11月 1 09:48 ./
drwxr-xr-x 25 hc hc 4096 10月 31 19:52 ../
-rw-r--r-- 1 hc hc 0 11月 1 09:48 file1
-rw-r--r-- 1 hc hc 0 11月 1 09:48 file2
說明:
如果加入 -c 參數,當目标檔案不存在時,不會建立新檔案,如果目标檔案存在,則會修改檔案時間屬性為目前系統時間
touch -c file2
ll
-rw-r--r-- 1 hc hc 0 11月 1 09:50 file2