简体   繁体   English

在Linux上基于修改TIme查找文件

[英]Finding Files in Linux based on Modification TIme

假设在同一天修改/创建了文件,是否有办法在Linux中获取仅具有修改时间(例如大于5 am)的文件。

If you have GNU find then you can do: 如果您有GNU find则可以执行以下操作:

find . -name "*" -type f -newermt "2014-04-04 05:00:00"

From man page: man页:

-newerXY reference Compares the timestamp of the current file with reference. -newerXY 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. reference参数通常是文件名(其时间戳之一用于比较),但也可以是描述绝对时间的字符串。 X and Y are placeholders for other letters, and these letters select which time belonging to how reference is used for the comparison. X和Y是其他字母的占位符,这些字母选择属于参考的方式用于比较的时间。

  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 Some combinations are invalid; for example, it is invalid for X to be t. Some combinations are not implemented on all systems; for example B is not supported on all systems. If an invalid or unsupported combination of XY is specified, a fatal error results. Time specifications are interpreted as for the argu‐ ment to the -d option of GNU date. If you try to use the birth time of a reference file, and the birth time cannot be deter‐ mined, a fatal error message results. If you specify a test which refers to the birth time of files being examined, this test will fail for any files where the birth time is unknown. 

You can find file modified in the last day find / -type f -mtime -1 您可以找到在最后一天修改过的文件find / -type f -mtime -1

or 要么

##  (year 2014 April day 05 time 05:00:00)
touch -t 201404040500.00 ~/myfile

## Find all files newer then myfile 
find / -newer ~/myfile

Hope that helps 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM