gpt4 book ai didi

linux - 在 Linux 中查找在给定文件之前和之后 30 分钟创建的文件

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:18:19 24 4
gpt4 key购买 nike

我需要使用另一个文件的创建时间来查找文件。例如,如果我在 21:00 创建了一个特定日期的文件,之后我想查找在该日期之后 30 分钟内创建的所有文件,或者。

因为我是新手,所以我对find 非常困惑。任何帮助将不胜感激!

最佳答案

您可以使用 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"

这是手册页中涵盖 newerXY 的部分

-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.

关于linux - 在 Linux 中查找在给定文件之前和之后 30 分钟创建的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26826798/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com