find 根据文件状态修改时间来查找文件

find 命令可以根据文件的创建时间和访问时间来查找相应的文件,分别可以用 -ctime-atime 选项。

帮助文档给出了如下的解释

-atime n
       File was last accessed less than, more than or exactly 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 less than, more than or exactly n*24 hours ago.  See the comments for -atime to understand how rounding affects the  interpretation  of
       file status change times.

如何查找一周以前创建的文件?这里一周就是7天。可以用 -ctime 选项,

假设 find 的查找路径是 /tmp

sudo find /tmp -ctime +6

注意这里忽略了当天的部分,所以7天前实际是用 +6 来表示。而 +1 实际上是表示至少两天以前。

那么 -ctime -1-ctime +0 分别表示什么含义呢,这是一个值得思考的问题。

(完)

关于本文如您有任何想法和意见,欢迎与我们联系,邮箱地址zhi@uqugu.com
您对本文有什么看法,喜欢或者不喜欢都可以发表意见。