我需要使用另一个文件的创建时间来查找文件。例如,如果我在21:00创建一个具有特定日期的文件,之后我想在其后30分钟内找到创建的所有文件。
因为我是新手,我对find
感到很困惑。任何帮助将不胜感激!
答案 0 :(得分:2)
您可以将find
与--newerXY
这允许您使用文件或日期作为时间段开始或结束的参考。
例如
find . -newermt "2014-11-09 12:00:00" ! -newermt "2014-11-09 12:30:00"
将在12:00:00和12:30:00之间找到已修改的所有文件
当然,您也可以提供一个文件作为开始或结束的参考
find . -newer somefile ! -newermt "2014-11-09 12:30:00"
以下是涵盖newXY
的联机帮助页的一部分-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
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 argument 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 determined, 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.