我尝试了文章中的所有建议: 5天后删除文件的脚本
当我运行不带参数的 find 时,-mtime
它会找到我正在寻找的文件。当我添加时-mtime +2
,什么也没有返回。我知道在使用该命令查找的目录中有相应日期的文件find
。
答案1
从man find
:
-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.
-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.
但另请参阅:
-daystart
Measure times (for -amin, -atime, -cmin, -ctime, -mmin, and -mtime) from the
beginning of today rather than from 24 hours ago. This option only affects tests
which appear later on the command line.
总之,用来find -mtime +1
查找 2 天前的旧文件。