【问题标题】:Unix find -mtime {a negative or postive value}Unix find -mtime {一个负数或正数}
【发布时间】:2014-12-30 06:57:37
【问题描述】:

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

【问题讨论】:

    标签: unix gnu-findutils


    【解决方案1】:

    根据手册页:

    -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 表示严格小于。

    所以在你的情况下,

    -4 表示少于 4 天。
    +4 表示超过 4 天,即 4*24 小时。

    【讨论】:

    • 谢谢!我得到了答案!
    【解决方案2】:

    嗯,我可以。

    -mtime n
    

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

    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
    

    【讨论】:

    • 感谢您的解决方案!但我知道这件事。我想知道如果我给出任何负值那是什么意思?
    • 不!我用过——查找。 -mtime -4 和查找。 -mtime +4 。他们给出不同的结果。
    • 你说得对,很抱歉,感谢您在这么长时间后纠正我。
    【解决方案3】:

    我的搜索——无论是“否定”、“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 已经给出了正确答案?好吧,很高兴知道这是法律上的,而不是令人愉快的意外。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-09
      • 2011-06-06
      • 1970-01-01
      相关资源
      最近更新 更多