linux下的touch命令

來源:互聯網
上載者:User

名稱:touch 
使用許可權:所有使用者
使用方式: 
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 可以顯示檔案的時間記錄。 
參數: 
a 改變檔案的讀取時間記錄。 
m 改變檔案的修改時間記錄。 
c 假如目的檔案不存在,不會建立新的檔案。與 --no-create 的效果一樣。 
f 不使用,是為了與其他 unix 系統的相容性而保留。 
r 使用參考檔的時間記錄,與 --file 的效果一樣。 
d 設定時間與日期,可以使用各種不同的格式。 
t 設定檔案的時間記錄,格式與 date 指令相同。 
--no-create 不會建立新檔案。 
--help 列出指令格式。 
--version 列出版本訊息。 
 
範例: 
最簡單的使用方式,將檔案的時候記錄改為現在的時間。若檔案不存在,系統會建立一個新的檔案。 
touch file 
touch file1 file2 
將 file 的時間記錄改為 5 月 6 日 18 點 3 分,公元兩千年。時間的格式可以參考 date 指令,至少需輸入 MMDDHHmm ,就是月日時與分。 
touch -c -t 05061803 file 
touch -c -t 050618032000 file 
將 file 的時間記錄改變成與 referencefile 一樣。 
touch -r referencefile file 
將 file 的時間記錄改成 5 月 6 日 18 點 3 分,公元兩千年。時間可以使用 am, pm 或是 24 小時的格式,日期可以使用其他格式如 6 May 2000 。 
touch -d "6:03pm" file 
touch -d "05/06/2000" file 
touch -d "6:03pm 05/06/2000" file 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.