1
To zip a folder in the Linux use the command below.
zip -r arquivoZipado.zip pastaSerZipada/
How can I zip, except for a subdirectory of pastureSerZipada?
1
To zip a folder in the Linux use the command below.
zip -r arquivoZipado.zip pastaSerZipada/
How can I zip, except for a subdirectory of pastureSerZipada?
2
The zip owns the flag -x
or --exclude
, which allows you to define file name masks and directories to be ignored during operation.
So to ignore the entire subdirectory subdir-fora-do-zip
compression of the following file structure...
para-zipar/
├─ arquivo-no-zip
├─ subdir-fora-do-zip/
│ └─ arquivo-fora-do-zip
└─ subdir-no-zip
└─ arquivo-no-zip
...execute:
zip -r zipado.zip para-zipar -x '*subdir-fora-do-zip*'
Obs.: Asterisks are important to ensure that the directory in question is ignored regardless of the level of recursion it is at.
By testing the compressed file, one can check the success of the use of flag -x
:
$ unzip -t zipado.zip Archive: zipado.zip testing: para-zipar/ OK testing: para-zipar/arquivo-no-zip OK testing: para-zipar/subdir-no-zip/ OK testing: para-zipar/subdir-no-zip/arquivo-no-zip OK No errors detected in compressed data of zipado.zip.
Browser other questions tagged linux zip-file
You are not signed in. Login or sign up in order to post.