Trying to exclude a set of directories from a find is driving me nuts! What I want to do is look for all .java files in a directory tree, but ignore all those in test directories. So, I've tried:
find . -name "*.java" -not -path "test"
and
find . -name "*.java" -path "test" -prune
and several variations thereof. However - depending on the variation - I either get all the java files (including those in test directories), or none of them. I looked at other questions here on SU (e.g. this one and this one), but either they don't address my situation, or I'm missing something.
I'm using gnu find 4.2.27 (fwiw, on centos 5.5 w/ gnu bash 3.2.25).
Edit: Sorry, I should have originally specified that I need to do a
-exec grep blah {} \;
so piping through grep -v won't work for me in this situation.
