Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a bash script that does something like this:

zip -0 ../backup/backup.zip \
-r ./* \
-x \*CVS\* \
-x *Thumbs.db* \

The directory it's backing up is a SVN archive (it used to be CVS back in the day). I've been unable to get it to exclude .svn and it's contents. What's the cleanest way to exclude .svn (recursively through the entire tree)?

share|improve this question
zip -0 ../backup/backup.zip -r . -x "*CVS*" "*Thumbs.db*" "*.svn*"

-x also accepts a list of excludes.

Alternatively, create a filelist with your excludes and add them there.
The exclude.lst:


with the command:

zip -0 ../backup/backup.zip -r . -x@exclude.lst
share|improve this answer
-x "*CVS*" excludes any file or directory whose name contains CVS as a substring (ditto for .svn). – Gilles Jan 27 '11 at 19:16
zip ../backup/backup.zip \
  -x '/CVS/*' -x '*/CVS/*' \
  -x '/.svn/*' -x '*/.svn/*' \
  -x '/Thumbs.db' -x '*/Thumbs.db' \
  -r .

Note that your exclude patterns as posted aren't quite right, they exclude any file or directory whose name contains CVS.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.