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-printthe default action applies to all branches, even pruned ones. – ninrod Feb 25 '16 at 04:59-printmake it to be applied for the whole expression. – cuonglm Feb 25 '16 at 05:22*/.gitwhilefindneeds us to say both*/.gitand*/.git/*when using predicate only. Why is that? – ninrod Feb 25 '16 at 12:35*/.gitcan not match something likefoo/.git/bar. – cuonglm Feb 25 '16 at 12:43*/.gitmatches something likefoo/.git/barin the first case with-prune? – ninrod Feb 25 '16 at 12:49-prunepreventfindfrom looking into.gitdirectory, any directories inside were ignored. – cuonglm Feb 25 '16 at 13:10-prunehas the downside thatfindwill recurse into.gitdirectories and try every file there. This could be a performance hit. – Gilles 'SO- stop being evil' Feb 25 '16 at 21:31-name .git -pruneis essentially the same thing as-path '*.git' -prune, but-pathhas better performance. Is that correct? – ninrod Feb 27 '16 at 13:58