按名称查找超过60天的目录

时间:2015-12-07 10:42:06

标签: bash unix directory find

我有一个包含一些文件和子目录的目录。在该目录中,我需要按名称模式“.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对我没有任何帮助。我做错了什么?

1 个答案:

答案 0 :(得分:0)

您正在寻找的-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.