Linux查找手册页中的以下示例似乎不起作用:
find repo/ -exec test -d {}/.svn \; -or \
-exec test -d {}/.git \; -or -exec test -d {}/CVS \; \
-print -prune
Given the following directory of projects and their associated SCM
administrative directories, perform an efficient search for the
projects' roots:
repo/project1/CVS
repo/gnu/project2/.svn
repo/gnu/project3/.svn
repo/gnu/project3/src/.svn
repo/project4/.git
In this example, -prune prevents unnecessary descent into directories
that have already been discovered (for example we do not search
project3/src because we already found project3/.svn), but ensures
sibling directories (project2 and project3) are found.
查找不显示输出。有人知道为什么吗?我注意到这个发现没有测试,因为“-exec”子句是动作而不是测试(动作也可以作为测试吗?)。并且由于“-or”的优先级低于最后一个“-exec”和“-print”之间隐含的“ - 和”,因此命令行中表示的逻辑似乎不是它的预期。
>uname -r
2.6.32-131.0.15.el6.x86_64
>pwd
/var/tmp
>mkdir -p repo/project1
>mkdir -p repo/gnu/project2
>mkdir -p repo/gnu/project3/src
>mkdir -p repo/project4
>touch repo/project1/CVS
>touch repo/gnu/project2/.svn
>touch repo/gnu/project3/.svn
>touch repo/gnu/project3/src/.svn
>touch repo/project4/.git
>find repo
repo
repo/project4
repo/project4/.git
repo/gnu
repo/gnu/project3
repo/gnu/project3/src
repo/gnu/project3/src/.svn
repo/gnu/project3/.svn
repo/gnu/project2
repo/gnu/project2/.svn
repo/project1
repo/project1/CVS
>find repo/ -exec test -d {}/.svn \; -or -exec test -d {}/.git \; -or -exec test -d {}/CVS \; -print -prune
>