SunOS: How to exclude directory in find command?

Hi All,

First my OS version is:

ksh:0$ uname -a
SunOS 5.9 Generic_122300-48 sun4u sparc SUNW,Sun-Fire-V440

I want to exclude the following DIR(./country111) in my search pattern:

ksh:0$ find . -name "*.tar"
./country111/COUNTRY_BATCH-801.tar
./country111/COUNTRY_BATCH-802.tar
./country111/COUNTRY_BATCH-803.tar

So I tried:

ksh:0$ find . -path './country111' -prune -o -name "*.tar" -print

Getting the output like this:

OUTPUT:
find: bad option -path
find: path-list predicate-list

Please Help.

Thanks,
Saptarshi

Hi saps19,

An option could be:

find . -name "*.tar" | nawk '!/\.\/country111/'

Regards

1 Like

It works perfectly...

U Rock!:slight_smile:

Thanks,
Sap.

You're welcome Sap,

This actually shows the output you want, but is not excluding the find command to search "tar" files within "./country111".

This would be no good thing if country111 directory contains a lot of files and subdirectories, in such case, the problem could be
get the output in more time than actually excluding this directory in the search. I hope country111 be a small size directory :smiley:

Regards