touch 常用於建立空檔案,或修改檔案的存取與修改時間。基本語法:
touch [option] 檔案
-a 只改存取時間;-m 只改修改時間;-c 不建立新檔;-d 指定日期時間;-t 使用 timestamp 格式;-r 參考其他檔案的時間。
touch test.txt
touch -a test.txt touch -m test.txt
也可指定日期:
touch -d "2016-05-14 15:00:00" test.txt touch -t 201605151600 test.txt
touch -r test_1.txt test_sunday.txt
此命令會讓 test_sunday.txt 的時間與 test_1.txt 一致。可用 stat 確認 Access、Modify、Change 三個時間戳的變化。