When i use the find command i use it with grep to find some pattern in files.

Usage:

find . -name "*.java" -exec grep "foobar" {] \; -print

If i want to search only in a specific directory (in the next example “source” ) i use :

find ./source -name "*.java" -exec grep "foobar" {] \; -print

But what if i want to exclude one or more sub directories from the search ?
The find man page gave us a answer and it looks ugly. Here is the solution:

find ./source \( -name directory -prune \) -o -name "*.java" -exec grep "foobar" {] \; -print

You have to exclude the directory by using the construction \( -name directory -prune \).
Very ugly :)