how to zip a directory with its files using Terminal on Mac

i am trying to zip a folder with files in terminal using

zip -r myzipfile.zip myDir

but this doesn't include the files What should i do ?

2 Answers

You can just use *; there is no need for .. File extensions are not special on Unix. * matches zero or more characters—including a dot. So it matches foo.png, because that's zero or more characters (seven, to be exact).

Note that * by default doesn't match files beginning with a dot (neither does .). This is often what you want. If not, in bash, if you shopt -s dotglob it will (but will still exclude . and ..). Other shells have different ways (or none at all) of including dotfiles.

You can use two commands: zip or ditto.

Using the zip command:

zip -r myzipfile.zip myDir/

or using the ditto command:

ditto -c -k --sequesterRsrc --keepParent myDir myzipfile.zip

Source:

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like