duanlou7910 2013-08-29 23:22
浏览 135
已采纳

Linux更改文件的修改日期?

I extract .php files in one of my directory and there were many files in there so most of the files replaced !

but I have a problem since the modification date of new files are 23 April 2013 so I want to find all files and folders in this directory that are not 23 April 2013 !

In other way, I want to change all files in this directory that have 23 April 2013 modification date to 30/08/2013 !

How its possible to find and change the files ?

Combine FIND and TOUCH function to replace all files modification date.

  • 写回答

1条回答 默认 最新

  • dreljie602951 2013-08-30 00:03
    关注

    You could cd to the folder containing the PHP files and:

    touch -d '30 August 2013' *.php
    

    Or if it has sub folders with php files - search through them recursively:

    find /path/to/your/php/ -exec touch -d '30 August 2013' *.php {} \;
    

    the folder 'php' in the command above would be included.

    Edit:

    If you ONLY need to find/change EXACTLY files modified on 23 April 2013, you can use the -mtime parameter in your find command.

    • -mtime +60 means you are looking for a file modified 60 days ago or more.

    • -mtime -60 means less than 60 days.

    • -mtime 60 If you skip + or - it means exactly 60 days.

    So modifying the command above like this:

    find /path/to/your/php/ -mtime 127 -exec touch -d '30 August 2013' *.php {} \;
    

    Where 127 is the exact amount of days since 23 April (if my quick head calculation is correct). Else you can change the number to the correct amount of days, or use the + or - as described above if it doesn't need to be 'that' exact.

    You can read more about the find commands -mtime parameter here: http://www.cyberciti.biz/faq/howto-finding-files-by-date/

    (yes I borrowed 3 lines from there)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站