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

标签 linux opensuse gnome-terminal setuid

我需要使用另一个文件的创建时间来查找文件。例如,如果我在 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/

相关文章:

archlinux - 启动 gnome-terminal 结果为 "Error constructing proxy..."

php - 从远程服务器执行 gnome-terminal

linux - 从 bash 打开多个 gnome 终端并执行 sudo 服务

c++ - 段错误,没有核心转储

linux - 尝试使用 grep、sed 等时如何处理颜色代码

linux - 如何在 openSUSE 11.3 上安装 libgdal?

mysql - 为 AES 256 位编译 mysql

linux - makefile出错时如何运行特定命令?

linux - 如何在 Linux 中跨多行查找模式?

java - 模态对话框位于 Opensuse 上其他窗口的背面