在find命令中newermt是什么意思?


14

我知道我可以使用此选项在特定修改时间之间查找文件。但是我很好奇这是什么意思?

我曾经man find | grep newermt尝试寻找一些东西。但是我没有直接的满足感。看来-newer filemtime东西可能与此有关。但我不确定。

那么,-newermt实际上是什么意思呢?

Answers:


20

find(1)

-newerXY reference
          Compares the timestamp of the current file with reference.   The
          reference  argument  is  normally the name of a file (and one of
          its timestamps is used for the comparison) but it may also be  a
          string  describing  an  absolute time.  X and Y are placeholders
          for other letters, and these letters select which time belonging
          to how reference is used for the comparison.

          a   The access time of the file reference
          B   The birth time of the file reference
          c   The inode status change time of reference
          m   The modification time of the file reference
          t   reference is interpreted directly as a time

12

find ./ -mtime +n用于使所有文件早于n过去
find ./ -mtime -n用于修改前n几天所有文件的日期
现在,如果您使用1代替n,则将在最近24小时内修改文件。但是,如果您只想要昨天的文件而不是最近24小时的文件怎么办?这newermt是图片。

find ./ -newermt "2016-01-18" ! -newermt '2016-01-19'

将为您提供所有比指定日期新的文件,并!排除所有比指定日期新的文件。因此,上面的命令将提供在2016-01-18修改的文件列表。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.