I'm trying to zip a directory (on Unix via SSH) but I need to exclude a couple of subdirectories (and all files and directories within them).

So far I have this:

zip -r myarchive.zip dir1 -x dir1/ignoreDir/**/* 

That doesn't seem to work though.

I also tried

zip -r myarchive.zip dir1 -x dir1/ignoreDir1/* dir1/ignoreDir2/*

However that will still include subdirectories within ignoreDir1 and ignoreDir2.

The subdirectory structure in the directories that I want to exclude is quite substantial so I can't simply add each directory to the -x argument.

Does anyone know how to do this?

link|improve this question
feedback

migrated from stackoverflow.com Jul 19 '11 at 11:58

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 2 down vote accepted

I was so close!

The actual command I need is:

zip -r myarchive.zip dir1 -x dir1/ignoreDir1/**\* dir1/ignoreDir2/**\*
link|improve this answer
Cool, and thanks for following up! You can accept your own answer, by the way. – Daniel Jul 20 '11 at 3:43
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.