I have a directory with the following files and a .git
directory, e.g.
.
├── .git
│ ├── branches
│ ├── COMMIT_EDITMSG
│ ├── packed-refs
│ └── refs
├── readme.md
├── server_build.sh
└── tags
If I run GNU find
command with the -prune
test, find
prints the directory which is prune
'd:
% find . -name '.git' -prune
./.git
If add another OR option, then the directory which is pruned not longer appears in the output:
% find . -name '.git' -prune -o -name '*.md' -print
./readme.md
In this case, both -name '.git'
and -name '*.md'
tests must be returning true, it can't be possible that adding another OR test suddenly makes the -name '.git' -prune
test untrue.
Is there some implicit switch being added to the first statement?
In other words is find turning
find . -name '.git' -prune
into
find . -name '.git' -prune -print
at run time? and the implicit -print
is taken away when the next test when is added?
Why doesn't find
print the -prune'd directory when another "-or" test is applied?
find . \( -name '.git' -prune -o -name '*.md' \) -print
also there is some discussion on this inman find
just beforeEXIT STATUS
– Sundeep Jul 19 '16 at 06:10find . -name '.git' -prune
prints.git
because there is no other action. On the other hand,find . -name '.git' -prune -o -name '*.md' -print
is actually equivalent tofind . \( -name '.git' -prune \) -o \( -name '*.md' \) -a -print
, and-prune
no longer prints anything since there is another action. – Satō Katsura Jul 19 '16 at 06:23-prune
was an action, and therefore the implicit-print
would not be used here. – the_velour_fog Jul 19 '16 at 06:26-prune
is not a test, it's an action. – Henrik supports the community Jul 19 '16 at 06:42