Solution for: #92: zip command exclude .svn directories
The gotcha for zip --exclude is to treat the entire relative path as the original string
- yliu on April 25, 2010, 09:49 PM UTC
The correct incantation is
You can also add a
--exclude=*.DS_Store* to exclude the annoying Mac OS X directory display metadata files.
Notice that the expression passed to --exclude is using the entire original relative directory path as the original string to match against. So .svn/* by itself doesn't work; the wildcard character in front ensures that it matches .svn directories anywhere in the directory tree.
zip -9 -r --exclude=*.svn* foo.zip [directory-to-compress]
You can also add a
--exclude=*.DS_Store* to exclude the annoying Mac OS X directory display metadata files.
Notice that the expression passed to --exclude is using the entire original relative directory path as the original string to match against. So .svn/* by itself doesn't work; the wildcard character in front ensures that it matches .svn directories anywhere in the directory tree.
Comments
But we need to use quotes, lest the shell processes the wildcards before zip sees them:
zip -9 -r "--exclude=*.svn*" foo.zip [directory-to-compress]
— ronald on November 28, 2014, 03:48 PM UTCWouldn't it also exclude files like myfile.svnext ? :-)
— Alexander on November 18, 2015, 08:13 PM UTCWhat would you suggest then?
— AlexandAr on May 16, 2019, 06:26 PM UTC