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
| Option | Description |
|---|---|
-r | Travel the directory structure recursively. |
-e | Encrypt the contents of the zip archive using a password. |
-q | Quiet mode; suppress informational messages. |
-u | Update (replace) existing files in the archive if they are newer. |
-9 | Compress better (slower). |
Real-world Examples
-
Create a zip archive containing multiple files:
zip archive.zip file1.txt file2.txt -
Zip an entire directory recursively:
zip -r project_backup.zip /path/to/project -
Create a password-protected zip file:
zip -e secure_data.zip confidential.pdf -
Update an existing zip file with newer files:
zip -u archive.zip file1.txt