bash 列出过去 5 分钟内修改的所有文件,不包括 .svn 目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8347359/
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
List all files modified in last 5 minutes excluding .svn directories
提问by Lekensteyn
I want to list all files modified within the last 5 minutes, excluding .svn
directories.
我想列出过去 5 分钟内修改的所有文件,不包括.svn
目录。
I've worked together the following script which does not seem to abide by any -atime
or -ctime
params.
我一起工作了以下脚本,它似乎不遵守任何-atime
或-ctime
参数。
find . -atime -5m -type d -name .svn -prune -o -type f -print
I feel like I'm digging myself into a hole that an extra set of eyes could spot easily.
我觉得我正在把自己挖进一个额外的眼睛很容易发现的洞里。
回答by Lekensteyn
Try a different order of arguments. Your command:
尝试不同的参数顺序。你的命令:
- If an entry is accessed within five minutes andis a directory andhas the name
.svn
, then the entry is ignored - otherwise, for all other cases, if it's a file, print the name
- 如果一个条目在五分钟内被访问并且是一个目录并且具有名称
.svn
,那么该条目将被忽略。 - 否则,对于所有其他情况,如果是文件,则打印名称
The following command prunes .svn
directories before descending into them:
以下命令.svn
在降序之前修剪目录:
find . -type d -name .svn -prune -o -mmin -5 -type f -print
If a file is a directory andhas the name .svn
, ignore it and do not descend into it either. Otherwise, if it is last modified (-mmin
) within 5 minutes anda file, print the filename.
如果文件是一个目录并且具有名称.svn
,则忽略它并且也不要进入它。否则,如果-mmin
在 5 分钟内最后修改 ( )并且是一个文件,则打印文件名。
回答by AlG
-atime
looks at the last accessed time. I think you're looking for -mmin
. I've only got cygwin handy so I can't test it...
-atime
查看上次访问的时间。我想你正在寻找-mmin
. 我只有 cygwin 方便所以我无法测试它...
回答by thiton
-and
is assumed between -atime
and -type d
, so you are pruning only SVN directories older than 5 minutes. Try:
-and
假定在-atime
和之间-type d
,因此您只修剪超过 5 分钟的 SVN 目录。尝试:
find . -type d -name .svn -prune -o -type f -mmin 5 -print