1821062 Members
2682 Online
109631 Solutions
New Discussion

find command and prune

 
SOLVED
Go to solution
dictum9
Super Advisor

find command and prune

This is on hp-ux 11.0

I need to run find and exclude NFS, CDFS as well as a few directories. I have the following command but it does not exclude dir1 nor dir2, why is that?


find / \( -fstype nfs -o -fstype cdfs -o -path /dir1 -o -path /dir2 \) -prune -print


 

 

P.S. This thread has been moved from HP-UX > System Administration to HP-UX > Languages. - Hp Forum Moderator

10 REPLIES 10
Pete Randall
Outstanding Contributor

Re: find command and prune

Try -name rather than -path.


Pete

Pete
Kent Ostby
Honored Contributor

Re: find command and prune

The way that's written, it's ONLY going to find those things.

"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Kent Ostby
Honored Contributor

Re: find command and prune

Sorry that last line was terrible grammer.

The way that's written, it's only going to find those paths.

"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
dictum9
Super Advisor

Re: find command and prune

I have the following and it still does not work, meaning it still find directories /dir1 and /dir2.
What can be done to fix it?


find / ! \( -fstype nfs -o -fstype cdfs -o -name /dir1 -o -name /dir2 \) -print
john korterman
Honored Contributor

Re: find command and prune

Hi,

prune does not exclude, try the not operator instead, e.g.:

# find / -type f \( ! -fstype nfs ! -fstype cdfs ! -path "/dir1/*" ! -path "/dir2/*" \)

regards,
John K.
it would be nice if you always got a second chance
Rodney Hills
Honored Contributor
Solution

Re: find command and prune

Try-
find / ! \( -fstype nfs -o -fstype cdfs -o -path "/dir1/*" -o -path "/dir2/*" \) -print

HTH

Rod Hills
There be dragons...
Rodney Hills
Honored Contributor

Re: find command and prune

Actually, I think this should work better-
find / \( -fstype nfs -o -fstype cdfs -o -path /dir1 -o -path /dir2 \) -prune -o -print

Same as what you had before, only put "-o" between -prune and -print.

HTH

-- Rod Hills
There be dragons...
dictum9
Super Advisor

Re: find command and prune

find / ! \( -fstype nfs -o -fstype cdfs -o -path "/dir1/*" -o -path "/dir2/*" \) -print

This one worked, thank you. Turns out you don't need prune. Still a mystery to me why prune didn't work.
Geoff Wild
Honored Contributor

Re: find command and prune

Why not just do:

 

find / -fsonly vxfs -name FILENAME

 

Rgds...Geoff

Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Dennis Handly
Acclaimed Contributor

Re: find command and -prune

>Why not just do: find / -fsonly vxfs -name FILENAME

 

That won't exclude those two directory paths.

 

>Turns out you don't need -prune. 

 

-prune is needed so you don't keep finding (and excluding) files under the highest directory possible.