Using FIND but ignoring selected folders

This may be ludicrously easy to most people, but I've been scratching my head today trying to do it.

I'm archiving data on a OpenServer 5.0.6a box using a combination of FIND, CPIO and BZIP2.

What I'd like to do is archive a range of folders, but ignore some.

For instance, if I have 5 folders:

/test1
/test2
/test3
/test4
/test5

how do I cpio test1 to test4, but ignore test5?

I've been trying to use find . ! - name test5

But it just ignores the folder, not the files in the folder.

Hope I've explained that sufficiently.

Many thanks for any advice.

---------- Post updated 04-03-13 at 12:00 AM ---------- Previous update was 03-03-13 at 11:42 PM ----------

I think I've figured this out:

find . | grep -v test5/

You could also try:

find . \( -name test5 -prune \) -o -print

or if you only want files rooted in test1, test2, test3, and test4 (and not other files in the current directory):

find test[1-4]
1 Like