We help IT Professionals succeed at work.

'find' - Exclude one directory

leonst
leonst asked
on
I'm trying to backup a SCO UnixWare 7.1.0 system from the shell using find/cpio. Trouble is I don't want to backup one very large directory and I wondered if there is 'find' syntax to do this?

The closest I can get is
find . \( -name 'user1' -prune -o -name '*' \)

(user1 being the directory to be excluded) but this still returns the name of the directory. Is there a way to stop 'find' showing the directory *and* contents?

Thanks in advance for any help.
Comment
Watch Question

Commented:
find . -path './user1' -prune -o -print

Author

Commented:
Thanks for your response. Unfortunately, on my system the -path switch doesn't exist (I assume that '-path' was meant literally and not as a variable) and a quick look on other systems (http://www.computerhope.com/unix/ufind.htm, http://www.mkssoftware.com/docs/man1/find.1.asp) seems to suggest that most Unices don't support this.

What does '-path' do and is there a way to do it long hand?
Commented:
My post was based on Linux.

On my Solaris 7 box the following seems to work as you want....

find . -name user1 -prune -o -print

What Unix are you using?

Cheers - Gavin

Author

Commented:
Spot on, many thanks!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.