Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

2 Answers 2

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:

*CVS*
*Thumbs.db*
*.svn*
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
add comment
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
add comment

Your Answer

 
discard

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