zoukankan      html  css  js  c++  java
  • linux 修改文件时间

    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 testtime3
    2、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 -0700
    3、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 -0700
    4、 touch -a -t 199803030504 testtime3
    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: 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不改变】
     
  • 相关阅读:
    eclipse技巧总结
    java中的全等和相似
    curl命令
    tr命令
    Ubuntu下安装支付宝安全控件
    Firefox about
    Ubuntu Terminal Shortcut
    ulimit
    ajax post(copy part)
    getopt
  • 原文地址:https://www.cnblogs.com/bluewelkin/p/3990269.html
Copyright © 2011-2022 走看看