Unix查找-mtime {负值或正值}

时间:2014-12-30 06:57:37

标签: unix gnu-findutils

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

3 个答案:

答案 0 :(得分:4)

嗯,我可以。

-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

答案 1 :(得分:4)

根据手册页:

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

-mtime的参数被解释为文件时代的整天数。 -mtime +n表示严格大于-mtime -n表示严格小于。{/ p>

所以在你的情况下,

-4意味着不到4天 +4意味着超过4天,即4 * 24小时。

答案 2 :(得分: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已给出正确答案)时,谁需要手册页?好吧,很高兴知道这是法律上的事情,而不是一次不幸的事故。