按名称查找超过 60 天的目录
Find directories that are older than 60 days by name
我有一个包含一些文件和子目录的目录。在该目录中,我需要按名称模式“.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 对我没有任何作用。我做错了什么?
您要找的是-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.
我有一个包含一些文件和子目录的目录。在该目录中,我需要按名称模式“.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 对我没有任何作用。我做错了什么?
您要找的是-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.