I'm trying to recursively include some folders in my zip, using a terminal command, for example, let's say that I have this:


I want my zip file to include folder1 content and its subdirectories contents, and the files in the root directory (file1 and file2)

Currently I have this command:

 zip -r myzip.zip ./ -i folder1/* -i ./*

But the resulting zip doesn't includes folder2

How can I fix it?

Thanks in advance.



zip -r myzip.zip . -i folder1/\* *

Notes on OP:

  • The * after folder1/ must be escaped.

  • The final * is substituted by the shell with the files in the root folder (.) nonrecursively, meaning not including folder3. The syntax -i ./\* would pick up these files recursively, including folder3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.