zip(1)
Create or modify compressed archive files in ZIP format.
Synopsis
zip [OPTION]... [-b path] [-t mmddyyyy] [-n suffixes] [zipfile [file]...]Description
The zip command compresses files into a single archive in ZIP format, compatible with Windows and most other systems. It preserves file permissions and directory structure by default, and can update existing archives incrementally.
When no files are specified, zip reads a list from standard input. Directories are recursively archived unless -r is omitted. Original files remain unchanged unless -m is used to move them into the archive.
Common options
| Flag | What it does |
|---|---|
-r | Recursively include all files and subdirectories |
-e | Encrypt archive with a password (prompts for input) |
-m | Move files into archive (delete originals after zipping) |
-q | Quiet mode; suppress informational messages |
-u | Update archive; only add or replace newer files |
-d | Delete entries from existing archive |
-l | Store files with Unix line endings (LF) instead of CRLF |
-0 | Store files without compression (store only) |
-9 | Maximum compression (slowest; default is -6) |
-j | Junk paths; store only file names, not directory structure |
-x | Exclude files matching pattern (e.g., -x '*.log') |
-v | Verbose; print filenames and compression ratios |
Examples
Create a new ZIP archive with two files
zip archive.zip file1.txt file2.txtRecursively archive an entire directory and its contents
zip -r project.zip myproject/Create a password-protected archive (prompts for password)
zip -e secure.zip important.docUpdate existing archive, adding or replacing only newer .txt files
zip -u backup.zip *.txtMove all .log files into archive and delete the originals
zip -m archive.zip logs/*.logArchive a directory while excluding .tmp and .cache files
zip -r -x '*.tmp' '*.cache' archive.zip project/Archive without compression (faster for already-compressed files)
zip -0 -r nocompress.zip media/Remove a file from an existing ZIP archive
zip -d archive.zip oldfile.txt