linux 修改檔案時間

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   使用   ar   檔案   div   

 

1、ls -l *.sh

2、touch -d "10/13/2013" *.sh 【我想把所以的.sh檔案修改到三個月前(2013年10月13)的時間。】
3、ls -l *.sh

參考文章

http://blog.itpub.net/29283412/viewspace-1070106/

 

另外也可以單獨修改時間或者月份,如下
以使用 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 以前面這一個檔案的時間去修改後面這個檔案的時間touch -r /bin/rm today 例子一:1、touch testtime32、stat testtime3  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 153367      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-09-23 20:38:16.160006062 -0700
Modify: 2014-09-23 20:38:16.160006062 -0700
Change: 2014-09-23 20:38:16.160006062 -07003、touch -m -t 199803030504 testtime3 【變更檔的最後一次修改時間為1998-03-03】stat testtime3  File: `testtime3‘
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 153367      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2014-09-23 20:38:16.160006062 -0700
Modify: 1998-03-03 05:04:00.000000000 -0800 【只有這裡有改變】
Change: 2014-09-23 20:39:30.670005854 -07004、 touch -a -t 199803030504 testtime3stat testtime3  File: `testtime3‘
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 802h/2050d      Inode: 153367      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 1998-03-03 05:04:00.000000000 -0800 【只有這裡有改變】
Modify: 1998-03-03 05:04:00.000000000 -0800
Change: 2014-09-23 20:40:01.014005560 -0700【註:已測。如果是這樣touch -t 199903030504 testtime4。Access time 和Modify time都改變了,Change time不改變】 參考文獻:http://blog.sina.com.cn/s/blog_6c9d65a10100msfy.html

linux 修改檔案時間

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.