代码之家  ›  专栏  ›  技术社区  ›  Maarten

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

  •  3
  • Maarten  · 技术社区  · 16 年前

    我试图找到所有与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)的做法行不通,它们仍然会出现。 有人对如何从我的搜索结果中找出他们有什么建议吗?

    1 回复  |  直到 16 年前
        1
  •  2
  •   sorpigal    16 年前

    由于混合布尔和、或总是失败的原因,这是失败的。

    你说的是真的(伪代码):

    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也返回true,所以您可以看到,没有一个ANDs与是否有或匹配有关。小心地使用括号可能会得到你想要的结果。