5

做什么find -mtime -4find -mtime +4做什么?我无法理解手册页中给出的示例。

4

3 回答 3

9

嗯,我可以。

-mtime n

文件的数据最后一次修改是在 n*24 小时前。请参阅注释-atime以了解舍入如何影响文件修改时间的解释

find . -mtime 0   # find files modified between now and 1 day ago
                  # (i.e., within the past 24 hours)
find . -mtime -1  # find files modified less than 1 day ago
                  # (i.e., within the past 24 hours, as before)
find . -mtime 1   # find files modified between 24 and 48 hours ago
find . -mtime +1  # find files modified more than 48 hours ago
于 2014-12-30T07:01:17.337 回答
8

根据手册页:

-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.

参数 to-mtime被解释为文件期限中的整天数。-mtime +n表示严格大于,-mtime -n表示严格小于。

所以在你的情况下,

-4意思是不到4天。
+4表示超过 4 天,即 4*24 小时。

于 2014-12-30T07:06:51.680 回答
0

我的搜索——无论是“否定”、“mtime”、“严格”——都没有在手册页中找到规范文本,但它就在那里,哦,四分之一的路:

   Numeric arguments can be specified as

   +n     for greater than n,

   -n     for less than n,

   n      for exactly n.

但是,当 Google 的顶级比赛是 Stack Overflow 时,谁还需要手册页,@SMA 和 @wgitscht 已经给出了正确答案?好吧,很高兴知道这是法律上的,而不是一个快乐的意外。

于 2020-11-06T16:55:03.800 回答