Skip to main content

zip

The zip command is a compression and file packaging utility. It creates .zip archives, which are widely compatible across different operating systems, including Windows and macOS.

Basic Syntax

zip [OPTIONS] zipfile file...

Common Options

OptionDescription
-rTravel the directory structure recursively.
-eEncrypt the contents of the zip archive using a password.
-qQuiet mode; suppress informational messages.
-uUpdate (replace) existing files in the archive if they are newer.
-9Compress better (slower).

Real-world Examples

  1. Create a zip archive containing multiple files:

    zip archive.zip file1.txt file2.txt
  2. Zip an entire directory recursively:

    zip -r project_backup.zip /path/to/project
  3. Create a password-protected zip file:

    zip -e secure_data.zip confidential.pdf
  4. Update an existing zip file with newer files:

    zip -u archive.zip file1.txt