从查找中排除某些文件名模式和目录

发布于 2024-10-03 01:53:45 字数 551 浏览 5 评论 0原文

我正在尝试查找与 CVS 相比不是最新的所有文件。由于我们的 CVS 结构已损坏(它在某些目录中不能很好地递归),所以我现在正在尝试使用 find 来解决它。

我现在所拥有的是这样的:

for i in `find .  -not \( -name "*\.jpg" \) -path './bookshop/mediaimg' -prune -o -path '*/CVS*' -prune -o  -path './files' -prune  -o -path './images/cms' -prune -o -path './internal' -prune -o -path './limesurvey171plus_build5638' -prune  -o -path './gallery2' -prune -o  -print  `; do cvs status  "$i" |grep Status ; done &>~/output.txt

但不知何故,我排除图像(在本例中为 jpg)的尝试不起作用,它们仍然出现。 有人对如何将它们从我的查找结果中删除提出建议吗?

I'm trying to find all files that are not up to date compared to CVS. As our CVS structure is broken (it does not recurse well in some directories) I'm trying to work around it with find for now.

What I have now is this:

for i in `find .  -not \( -name "*\.jpg" \) -path './bookshop/mediaimg' -prune -o -path '*/CVS*' -prune -o  -path './files' -prune  -o -path './images/cms' -prune -o -path './internal' -prune -o -path './limesurvey171plus_build5638' -prune  -o -path './gallery2' -prune -o  -print  `; do cvs status  "$i" |grep Status ; done &>~/output.txt

But somehow my attempt at excluding images (jpg in this case) does not work, they still show up.
Anyone have a suggestion on how to get them out of my results from find?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨轻弹 2024-10-10 01:53:45

这失败的原因与混合布尔 AND 和 OR 总是失败的原因相同。

你在这里所说的是真的(用伪代码):

If (
    File Not Named '*.jpg' AND
    Path Matches './bookshop/mediaimg' AND
    Prone OR
    Path Matches '*/CVS*' AND
    Prune OR
    Path Matches './files' AND
    Prune OR
    Path Matches './images/cms' AND
    Prune OR
    Path Matches  './internal' AND
    Prune OR
    Path Matches  './limesurvey171plus_build5638' AND
    Prune OR
    Path Matches  './gallery2' AND
    Prune OR
    Print
)

现在, print 总是返回 true,我认为 prune 也是如此,所以你会看到,如果任何 OR 匹配,则所有 AND 都不重要。仔细应用括号可能会产生您想要的结果。

This is failing for the same reason that mixing boolean AND and OR always fails.

What you're saying here is really (in pseudo-code):

If (
    File Not Named '*.jpg' AND
    Path Matches './bookshop/mediaimg' AND
    Prone OR
    Path Matches '*/CVS*' AND
    Prune OR
    Path Matches './files' AND
    Prune OR
    Path Matches './images/cms' AND
    Prune OR
    Path Matches  './internal' AND
    Prune OR
    Path Matches  './limesurvey171plus_build5638' AND
    Prune OR
    Path Matches  './gallery2' AND
    Prune OR
    Print
)

Now, print always returns true, and I think prune does as well, so you see that none of the ANDs matter if any OR matches. The careful application of parentheses will probably yield the results you're after.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文