I want to list only the directories that are not inside a .git/ directory on my current path.
I'm trying this:
find . -path "**/.git" -prune -o -print -type d
The .git dirs are excluded, but the snippet is also listing files. But it should not as I specified -type d
. How to make the find
utility behave as I described?
-print
, than it all works as I want. Why that happens? That's really unexpected. – ninrod Feb 25 '16 at 04:54-print
the default action applies to all branches, even pruned ones. – ninrod Feb 25 '16 at 04:59-print
make it to be applied for the whole expression. – cuonglm Feb 25 '16 at 05:22*/.git
whilefind
needs us to say both*/.git
and*/.git/*
when using predicate only. Why is that? – ninrod Feb 25 '16 at 12:35*/.git
can not match something likefoo/.git/bar
. – cuonglm Feb 25 '16 at 12:43*/.git
matches something likefoo/.git/bar
in the first case with-prune
? – ninrod Feb 25 '16 at 12:49-prune
preventfind
from looking into.git
directory, any directories inside were ignored. – cuonglm Feb 25 '16 at 13:10-prune
has the downside thatfind
will recurse into.git
directories and try every file there. This could be a performance hit. – Gilles 'SO- stop being evil' Feb 25 '16 at 21:31-name .git -prune
is essentially the same thing as-path '*.git' -prune
, but-path
has better performance. Is that correct? – ninrod Feb 27 '16 at 13:58