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

8,042

Solution 1

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.

https://unix.stackexchange.com/a/57014

Solution 2

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: https://www.polynique.com/operating-systems/how-to-zip-files-and-folders-in-macos-from-terminal/

Share:
8,042

Related videos on Youtube

Acs90
Author by

Acs90

Updated on September 18, 2022

Comments

  • Acs90
    Acs90 over 1 year

    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 ?