linux - 如何在 bash 中检查文件是否创建时间超过 x 时间?

我想在 linux bash 中检查一个文件是否是在 x 之前创建的。

假设文件名为 text.txt,时间为 2 小时。

 if [ what? ]
 then
     echo "old enough"
 fi

最佳答案

仅用于修改时间

if test `find "text.txt" -mmin +120`
then
    echo old enough
fi

您可以使用 -cmin 更改或 -amin 访问时间。正如其他人指出的那样,我认为您无法跟踪创建时间。

https://stackoverflow.com/questions/552724/

相关文章:

linux - 如何在命令行中合并图像?

linux - 如何将命令存储在 shell 脚本的变量中?

Python - doctest 与 unittest

c - Linux:是否有超时的套接字读取或接收?

linux - 有没有办法改变 Unix 中另一个进程的环境变量?

linux - 如何在 Bash 中解析 CSV 文件?

python - 在 Python 中注释函数的正确方法是什么?

python - 如何模拟在 with 语句中使用的 open (使用 Python 中的 Mock

python - 如何在 Python Django 中运行单元测试时禁用日志记录?

python - 为什么 4*0.1 的浮点值在 Python 3 中看起来不错,但 3*0.1 不