[英]Linux finding files -mtime
So my question is about using find -mtime (and atime & ctime as well). 所以我的问题是关于使用find -mtime(以及atime和ctime)。 As I already know -mtime -n searches files that are newer than n days, +n older than n days and -mtime n searches files exactly n days old. 据我所知,-mtime -n搜索比n天更新的文件,+ n比n天更早的文件,-mtime n搜索恰好n天的文件。 What if I want to find files that are newer than n days and exactly n days old? 如果我想查找比n天新,恰好n天旧的文件怎么办? Will find / -type f -mtime -n -mtime n
work? 会find / -type f -mtime -n -mtime n
工作吗? Or I just need to use find / -type f -mtime -n
? 或者我只需要使用find / -type f -mtime -n
? Or both as separate commands? 还是两者都作为单独的命令?
The most obvious solution is to add 1
to $n
when using it with -mtime
: 最明显的解决方案是在与-mtime
一起使用时将$n
加1
:
find / -type f -mtime -$((n+1))
But you could use -o
to combine conditions with OR
(the default combination is AND
): 但是您可以使用-o
将条件与OR
组合(默认组合为AND
):
find / -type f \( -mtime $n -o -mtime -$n \)
You can use the find
operators -o
or -or
to specify that you want either of your tests to succeed. 您可以使用find
运算符-o
或-or
来指定要使任何一个测试成功。
Your command should look like this: 您的命令应如下所示:
find / -type f \( -mtime -n -o -mtime n \)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.