Using the Terminal to Compress Files on macOS

April 11, 2023

Zipping files and folders is a common task on macOS, and it can be easily accomplished using the Terminal. In this tutorial, we'll show you how to use the zip command to create zip archives of files and folders.

The syntax for the zip command is straightforward. To create a zip archive of a folder named bar and save it as foo.zip, simply run the following command:

Terminal
zip -r foo.zip bar

The -r option tells zip to include all files and subfolders recursively. If you omit this option, zip only includes the files in the top-level folder.

You can also create a zip archive of multiple folders by specifying them as separate arguments:

Terminal
zip -r foo.zip bar baz qux

This will create a zip archive of the bar, baz, and qux folders and save it as foo.zip.

In addition to zipping files and folders, zip has many other options that allow you to customize the compression process. For example, you can password-protect zip archives, exclude specific files or folders, and more.

By mastering the zip command, you can streamline your file management tasks on macOS and save time.

Share this post on Twitter