bash 查找 1 小时前但不到 3 天修改过的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32922557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Find files modified over 1 hour ago but less than 3 days
提问by newUserNameHere
In linux, using bash, what's the easiest way to find files that were modified more than an hour ago but less than 3 days ago?
在 linux 中,使用 bash,查找一个多小时前但不到 3 天前修改过的文件的最简单方法是什么?
Surely, there's got to be an easy way to do this. I keep searching and can't find an easy solution.
当然,必须有一种简单的方法来做到这一点。我一直在寻找,但找不到简单的解决方案。
回答by borancar
Find has -mtime and -mmin:
查找有 -mtime 和 -mmin:
find . -mtime +3 -mmin -60
From the find manual:
从查找手册:
Numeric arguments can be specified as:
+n for greater than n
-n for less than n
n for exactly n
数字参数可以指定为:
+n 大于 n
-n 小于 n
n 正好 n
回答by TheodoreC
This should suffice: find . -mtime -3 -mmin +60
这应该足够了: find . -mtime -3 -mmin +60
I just tried it:
我刚试过:
find ./ -mtime -3 -mmin +60 -exec ls -lhrt {} \; | awk '{print $5" "$6" "$7" "$8}'
find ./ -mtime -3 -mmin +60 -exec ls -lhrt {} \; | awk '{print $5" "$6" "$7" "$8}'