Exclude directory in (native Solaris) find command

findsolaris

I'm trying to exclude the directory /zones in my find command. I don't have GNU find available, just the native Solaris find.

I tried something like this:

find / -type d ! -name zones

The problem is that with this exclude I also lose sub-directories like /etc/zones.

Is there a way to specify the complete directory name like:

find / -type d ! -name ^\/zones

I already tested lots of approaches but I can't include the / in front of the string.

Best Answer

Here is a portable way:

find / -type d -exec test {} = /zones \; -prune -o -type d -print

Note that GNU find might be available on an alternate directory depending on the Solaris release you are using (like /usr/sfw/bin/gfind, /usr/gnu/bin/find, ...).

Related Question