【问题标题】:Find directories that are older than 60 days by name按名称查找超过 60 天的目录
【发布时间】:2016-03-11 22:35:46
【问题描述】:

我有一个包含一些文件和子目录的目录。在该目录中,我需要按名称模式“.cm-2015.10.10”查找超过 30 天的文件。此命令为我找到所需的目录:

find comdit/ -type d -name .cm-[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9] -print

但是如何指定我只需要 60 天以前的文件夹?添加 -ctime +60 对我没有任何帮助。我做错了什么?

【问题讨论】:

    标签: bash unix directory find


    【解决方案1】:

    你要找的是-mtime

    find comdit/ -type d -mtime +30 -name .cm-[0-9][0-9][0-9][0-9].[0-9][0-9].[0-9][0-9] -print
    

    这里是文档:

       -atime n
              File was last accessed n*24 hours ago.  When  find  figures  out
              how  many  24-hour  periods  ago the file was last accessed, any
              fractional part is ignored, so to match -atime +1, a file has to
              have been accessed at least two days ago.
    
       -ctime n
              File's status was last changed n*24 hours ago.  See the comments
              for -atime to understand how rounding affects the interpretation
              of file status change times.
    
       -mtime n
              File's data was last modified n*24 hours ago.  See the  comments
              for -atime to understand how rounding affects the interpretation
              of file modification times.
    

    【讨论】:

      猜你喜欢
      • 2018-08-20
      • 1970-01-01
      • 1970-01-01
      • 2015-02-13
      • 1970-01-01
      • 2017-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多