In Linux zip, is it possible to zip a folder recursively except for a given sub-path?
For instance, to zip 'base_folder' and all its sub folders except 'base_folder/sub_folder'.
Is it possible? And if so, how?
Join Stack Overflow to learn, share knowledge, and build your career.
zip -r base_folder.zip base_folder -x base_folder/sub_folder/\* base_folder/another_sub_folder/\*
(I have incorporated the improved information from your experience that you have kindly offered in your comment.)
For more information: man zip
You can use tar
with --exclude
, and use the -z
option to gzip the output tar file.
find the files, exclude the folder, xargs the remaining files to tar or zip or whatever:
find /in/your/dir | grep -v 'name_of_dir_to_be_excluded' | xargs tar jcvf nameOfArchive.tar.bz2