bash 如何通过命令行列出昨天在目录中修改的文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9891614/
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
How can I list files modified within a directory yesterday via command line?
提问by Ryan
I'd like to list out all files with modification dates in the last ndays (or even simply afterY-m-d) in a directory. It must work recursively through all subdirectories as well.
我想列出目录中过去n天(甚至只是在Ymd之后)修改日期的所有文件。它也必须通过所有子目录递归工作。
How can I do this?
我怎样才能做到这一点?
Ideal output:
理想输出:
file.txt Mar 26 15:15
file2.txt Mar 27 01:15
Acceptable output:
可接受的输出:
file.txt
file2.txt
Answered!(Thanks for all the help)
回答了!(感谢大家的帮助)
$ find . -type f -mtime -1 -exec ls -lah {} \;
-rw-r--rw- 1 apache apache 18K Mar 26 08:22 ./file1.txt
-rw-r--rw- 1 apache apache 12K Mar 26 09:23 ./dir1/file2.txt
-rw-r--rw- 1 apache apache 16K Mar 26 10:24 ./dir1/dir2/file3.txt
回答by Alex
find . -type f -mtime -1 -exec ls -l {} \;
find . -type f -mtime -1 -exec ls -l {} \;
will list all files within last 24 hours, with a long listing just to confirm modification date
将列出过去 24 小时内的所有文件,并列出很长的列表以确认修改日期
回答by Arnaud F.
use :
用 :
find . -mtime +1
For more informations, see
有关更多信息,请参阅
man find
回答by Guido
find dir -mtime +1 -print
That will find all files in dir and subdirectories that were modified 1 day ago or before that.
这将找到 1 天前或之前修改的 dir 和子目录中的所有文件。

