Find command with ignore directory

Dear All,

I am using find command

find /my_rep/*/RKYPROOF/*/*/WDM/HOME_INT/PWD_DATA -name rk*myguidelines*.pdf -print

The problem i am facing here is find /my_rep/*/
the directory after my_rep could be mice001, mice002 and mice001_PO, mice002_PO

i want to ignore mice***_PO directory while search, and look for all other directory mice001, mice002 and so on...

Early help will be appriciated

Add a not (!) to the find command to exclude that directory.

i.e.

find /dir/path/ -name 'dir*' ! -name 'dir2'

That will exclude the directory itself, but not the tree beneath it; find will still descend into its contents and generate output. To prevent that, a -prune is required.

Further, since -name only looks at the basename, -name cannot match an absolute pathname. There could be many instances of dir2 within /dir/path.

A POSIX-compliant invocation will need to use -exec to call test/[ to check the full pathname (via {}). However, a few finds support a -path which can do the job more efficiently.

Regards,
Alister

I'm not sure why you have wild cards in the path. I would expect:

 find /my_rep/ -name "rk*myguidelines*.pdf" -print

---------- Post updated at 01:58 PM ---------- Previous update was at 01:52 PM ----------

Here is a "brute force" solution (often the best way), to avoid the complexities of prune option:

$ find /my_rep/ -name "rk*myguidelines*.pdf" -print > all.txt
$ grep -v "mice..._PO" all.txt > po_excluded.txt

If the find takes a few seconds, this will work. Of course, if the find is taking a while, this may not be good enough.