歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux系統命令及其使用詳解(大全):touch

Linux系統命令及其使用詳解(大全):touch

日期:2017/2/25 10:35:30   编辑:Linux教程
名稱: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

Copyright © Linux教程網 All Rights Reserved