国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Linux > 正文

Linux文件目錄時(shí)間更新touch命令用法

2024-08-27 23:59:37
字體:
供稿:網(wǎng)友

touch命令開始看成了權(quán)限命令后來發(fā)現(xiàn)touch命令是對(duì)目錄或文件進(jìn)行時(shí)間日期的一個(gè)更新操作了,下面來看一些簡單的例子.

名稱:touch

使用權(quán)限:所有使用者

使用方式:

  1. touch [-acfm] 
  2. [-r reference-file] [--file=reference-file] 
  3. [-t MMDDhhmm[[CC]YY][.ss]] 
  4. [-d time] [--date=time] [--time={atime,access,use,mtime,modify}] 
  5. [--no-create] [--help] [--version] 
  6. file1 [file2 ...] 

說明:touch 指令改變檔案的時(shí)間記錄,ls -l 可以顯示檔案的時(shí)間記錄.

參數(shù):

  1. a 改變檔案的讀取時(shí)間記錄。 
  2. m 改變檔案的修改時(shí)間記錄。 
  3. c 假如目的檔案不存在,不會(huì)建立新的檔案。與 --no-create 的效果一樣。 
  4. f 不使用,是為了與其他 unix 系統(tǒng)的相容性而保留。 
  5. r 使用參考檔的時(shí)間記錄,與 --file 的效果一樣。 
  6. d 設(shè)定時(shí)間與日期,可以使用各種不同的格式。 
  7. t 設(shè)定檔案的時(shí)間記錄,格式與 date 指令相同。 
  8. --no-create 不會(huì)建立新檔案。 
  9. --help 列出指令格式。 
  10. --version 列出版本訊息。 

使用范例:

實(shí)例一:創(chuàng)建不存在的文件

命令:touch log2012.log log2013.log

輸出:

  1. [root@localhost test]# touch log2012.log log2013.log 
  2. [root@localhost test]# ll  //Vevb.com 
  3. -rw-r--r-- 1 root root    0 10-28 16:01 log2012.log 
  4. -rw-r--r-- 1 root root    0 10-28 16:01 log2013.log 

如果log2014.log不存在,則不創(chuàng)建文件.

  1. [root@localhost test]# touch -c log2014.log 
  2. [root@localhost test]# ll 
  3. -rw-r--r-- 1 root root    0 10-28 16:01 log2012.log 
  4. -rw-r--r-- 1 root root    0 10-28 16:01 log2013.log 

實(shí)例二:更新log.log的時(shí)間和log2012.log時(shí)間戳相同.

命令:touch -r log.log log2012.log

輸出:

  1. [root@localhost test]# ll 
  2. -rw-r--r-- 1 root root    0 10-28 16:01 log2012.log 
  3. -rw-r--r-- 1 root root    0 10-28 16:01 log2013.log 
  4. -rw-r--r-- 1 root root    0 10-28 14:48 log.log 
  5. [root@localhost test]# touch -r log.log log2012.log  
  6. [root@localhost test]# ll 
  7. -rw-r--r-- 1 root root    0 10-28 14:48 log2012.log 
  8. -rw-r--r-- 1 root root    0 10-28 16:01 log2013.log 
  9. -rw-r--r-- 1 root root    0 10-28 14:48 log.log 

實(shí)例三:設(shè)定文件的時(shí)間戳

命令:touch -t 201211142234.50 log.log

輸出:

  1. [root@localhost test]# ll 
  2. -rw-r--r-- 1 root root    0 10-28 14:48 log2012.log 
  3. -rw-r--r-- 1 root root    0 10-28 16:01 log2013.log 
  4. -rw-r--r-- 1 root root    0 10-28 14:48 log.log 
  5. [root@localhost test]# touch -t 201211142234.50 log.log 
  6. [root@localhost test]# ll 
  7. -rw-r--r-- 1 root root    0 10-28 14:48 log2012.log 
  8. -rw-r--r-- 1 root root    0 10-28 16:01 log2013.log 
  9. -rw-r--r-- 1 root root    0 2012-11-14 log.log 

說明:-t  time 使用指定的時(shí)間值 time 作為指定文件相應(yīng)時(shí)間戳記的新值,此處的 time規(guī)定為如下形式的十進(jìn)制數(shù):

[[CC]YY]MMDDhhmm[.SS]    

這里,CC為年數(shù)中的前兩位,即”世紀(jì)數(shù)”;YY為年數(shù)的后兩位,即某世紀(jì)中的年數(shù),如果不給出CC的值,則touch 將把年數(shù)CCYY限定在1969--2068之內(nèi).MM為月數(shù),DD為天將把年數(shù)CCYY限定在1969--2068之內(nèi),MM為月數(shù),DD為天數(shù),hh 為小時(shí)數(shù)(幾點(diǎn)),mm為分鐘數(shù),SS為秒數(shù),此處秒的設(shè)定范圍是0--61,這樣可以處理閏秒,這些數(shù)字組成的時(shí)間是環(huán)境變量TZ指定的時(shí)區(qū)中的一個(gè)時(shí) 間,由于系統(tǒng)的限制,早于1970年1月1日的時(shí)間是錯(cuò)誤的.

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 垫江县| 开江县| 慈利县| 修水县| 阳原县| 咸阳市| 商都县| 闽清县| 杂多县| 新闻| 工布江达县| 焉耆| 江安县| 洱源县| 平凉市| 邢台市| 福泉市| 文水县| 洛隆县| 德江县| 雅江县| 大化| 忻州市| 印江| 汽车| 四平市| 宜宾县| 阜南县| 海口市| 三门峡市| 靖江市| 永春县| 嫩江县| 德保县| 灌阳县| 调兵山市| 北京市| 高台县| 新野县| 璧山县| 德庆县|