熱搜:win11繞過硬件限制安裝 一鍵重裝Win10系統(tǒng) 最干凈的u盤啟動盤 真正純凈版的win7系統(tǒng)
時間:2015-05-15 14:54:45 作者:小蘭 來源:系統(tǒng)之家 1. 掃描二維碼隨時看資訊 2. 請使用手機(jī)瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20150515/48468.html 手機(jī)查看 評論 反饋
Linux系統(tǒng)中touch命令是更新目錄或文件進(jìn)行時間日期的命令,不過還有許多用戶對touch命令還不太清楚,因此,小編今天就給大家介紹一下touch命令的用法吧。
touch命令使用技巧:
名稱:touch
使用權(quán)限:所有使用者
使用方式:
touch [-acfm]
[-r reference-file] [--file=reference-file]
[-t MMDDhhmm[[CC]YY][.ss]]
[-d time] [--date=time] [--time={atime,access,use,mtime,modify}]
[--no-create] [--help] [--version]
file1 [file2 ...]
說明:
touch 指令改變檔案的時間記錄。 ls -l 可以顯示檔案的時間記錄。
參數(shù):
a 改變檔案的讀取時間記錄。
m 改變檔案的修改時間記錄。
c 假如目的檔案不存在,不會建立新的檔案。與 --no-create 的效果一樣。
f 不使用,是為了與其他 unix 系統(tǒng)的相容性而保留。
r 使用參考檔的時間記錄,與 --file 的效果一樣。
d 設(shè)定時間與日期,可以使用各種不同的格式。
t 設(shè)定檔案的時間記錄,格式與 date 指令相同。
--no-create 不會建立新檔案。
--help 列出指令格式。
--version 列出版本訊息。
使用范例:
實例一:創(chuàng)建不存在的文件
命令:
touch log2012.log log2013.log
輸出:
[root@localhost test]# touch log2012.log log2013.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
如果log2014.log不存在,則不創(chuàng)建文件
[root@localhost test]# touch -c log2014.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
實例二:更新log.log的時間和log2012.log時間戳相同
命令:
touch -r log.log log2012.log
輸出:
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 16:01 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 10-28 14:48 log.log
[root@localhost test]# touch -r log.log log2012.log
[root@localhost test]# ll
-rw-r--r-- 1 root root 0 10-28 14:48 log2012.log
-rw-r--r-- 1 root root 0 10-28 16:01 log2013.log
-rw-r--r-- 1 root root 0 10-28 14:48 log.log
發(fā)表評論
共0條
評論就這些咯,讓大家也知道你的獨特見解
立即評論以上留言僅代表用戶個人觀點,不代表系統(tǒng)之家立場