【问题标题】:Find with mtime doesn't work使用 mtime 查找不起作用
【发布时间】:2014-10-25 11:44:43
【问题描述】:

我在家里创建了一个文件夹,并在里面触摸了一个文件。现在我正在执行

find /home -mtime 1

但它没有找到任何东西。这正常吗?

【问题讨论】:

    标签: linux bash shell find


    【解决方案1】:

    你需要使用:

    find /home -mtime -1
    

    根据man find

    -mtime n[smhdw]
        If no units are specified, this primary evaluates to true if the difference between 
        the file last modification time and the time find was started, rounded up to the next 
        full 24-hour period, is n 24-hour periods.
    
        If units are specified, this primary evaluates to true if the difference between the 
        file last modification time and the time find was started is exactly n units. 
    

    【讨论】:

      【解决方案2】:

      您必须根据需要将+- 添加到整数值。系统无法理解1默认为+1

      【讨论】:

      • 1 表示修改时间正好等于 1 天,而 +1 表示修改时间大于 1 天。 linux 中的 1 天是从当前时间开始的 24 小时持续时间,而不是日期的差异。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-26
      • 2015-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多