zip
file_compressionlinux
The zip command is one of the most frequently used commands in Linux/Unix-like operating systems. zip Package and compress (archive) files
Quick Reference
Command Name:
zip
Category:
file_compression
Platform:
linux
Basic Usage:
zip [options] [arguments]
Common Use Cases
Syntax
zip [options] zipfile files...
Options
## Common Options
| Option | Description |
|--------|-------------|
| -r | Recursively include files in directories |
| -e | Encrypt the contents of the zip file using a password |
| -u | Update existing entries if newer on the filesystem |
| -m | Move files into the zip archive (delete original files) |
| -j | Store just the file name (junk the path) |
| -0..9 | Set compression level (0=none, 9=maximum) |
| -q | Quiet mode (suppress normal messages) |
| -v | Verbose mode (show more information) |
| -l | Convert LF to CR LF (useful for creating zips for Windows) |
| -x | Exclude specified files from being added to the zip file |
| -i | Include only the specified files |
| -b | Specify path to use for temporary zip file |
| -@ | Read the list of files to be processed from stdin |
| -s | Create split archives (specify size e.g., -s 2g for 2GB) |
| -sf | Show files in the zip archive |
| -d | Delete entries from the zip file |
| -t | Test the integrity of the zip file |
| -z | Add a comment to the zip file |
| -n | Don't compress files with specified suffixes |
| -h | Display help information |
| -y | Store symbolic links as links rather than the file referenced |
| -k | Attempt to convert names and paths to be compatible with MS-DOS |
Examples
How to Use These Examples
The examples below show common ways to use the zip
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
# Compress a file
zip archive.zip file.txt