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?
Syntax : $zip –m filename.zip file.txt 4. -r Option: To zip a directory recursively, use the -r option with the zip command and it will recursively zips the files in a directory. This option helps you to zip all the files present in the specified directory.
Creating a zip folder allows files to be organized and compressed to a smaller file size for distribution or saving space. Zip folder can have subfolders within this main folder. Select the operating system below for instructions on how to zip and compress folders.
To create the new folder, navigate into the folder in which you wish to create your new folder, right-click and choose New Folder from the shortcut menu. The Create a Folder dialog will appear. The dialog shows the full path of the folder in the Zip file in which the new folder will be created.
The easiest way to zip a folder on Linux is to use the “zip” command with the “-r” option and specify the file of your archive as well as the folders to be added to your zip file. You can also specify multiple folders if you want to have multiple directories compressed in your zip file.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With