Question: I can't figure out how the find -not works.

Let's say that I would like to locate all .git dirs in the tree.

```
find -type d -iname .git

```

No problems, but then let's say that I have some dirs that I don't like to be included, in question they can be called "old" and "backup".

I could pipe to grep -v and that will work just fine.

```
find -type d -iname .git | grep -v old | grep -v backup

```

But when I browsed the man page for find I noticed that there is a -not, but I can't figure out how it is intended to work.

I tried like this, but he does not exclude the old dir.

```
find -type d -iname .git -not -iname old 

```

How does the find -not work? Can I use it for this find of problem?

Answer: 
find has a little bit of sophistication to deal with this case:

> 
> If the expression contains no actions other than `-prune`, `-print` is performed on all files for which the expression is true.
> 
> 
> 

So explicitly print just the parts you want:

```
find -type d \( -iname old -prune -o -iname backup -prune -o -iname .git -print \)

```

avoids searching the old and backup trees at all.
You could exclude the directories by specifying `-path`:

```
find . -type d \( -iname .git ! -path "*/old/*" ! -path "*/backup/*" \)

```

Note that `-not` in GNU `find` is the same as `!` but is not POSIX compliant.

Quoting from `man find`:

```
   ! expr True  if  expr  is false.  This character will also usually need
          protection from interpretation by the shell.

   -not expr
          Same as ! expr, but not POSIX compliant.

```