Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

Linux touch 命令:修改時間戳與建立檔案

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 三個時間戳的變化。

Copyright © Linux教程網 All Rights Reserved