Originally published on 2009-06-20; fully revised and updated.
This guide is for engineers who use command-line archiving in build scripts, release packaging, and backup workflows. You will learn the core zip options from the original post, how similar flags differ, and safe patterns for CI/CD usage.

What this cheatsheet actually covers
The original article title references WinZip, but the option set shown is the classic zip command syntax (for example -u, -f, -r, -T). This rewrite keeps that option set and organizes it for practical use. Source post: WinZip commands Web References & Cheatsheet.
Command format and default behavior
Per the original post, the default action is to add or replace entries in a zip file from the provided file list. The list may include the special name - to read from standard input. If both zipfile and list are omitted, input is read from stdin and written to stdout.
zip [options] zipfile [list...]Code language: CSS (css)
Core flags by job
| Flag | Best used for | What it does |
|---|---|---|
| -u | Incremental updates | Adds new files and updates changed files. |
| -f | Freshening existing archives | Updates only files already present in the archive. |
| -d | Cleanup | Deletes matching entries from the archive. |
| -m | Move-then-clean workflows | Moves files into archive and deletes originals. |
| -r | Directory trees | Recurses into subdirectories. |
| -j | Flat archive layout | Stores files without directory paths. |
| -i / -x | Inclusion/exclusion control | Include only matching names or exclude matching names. |
| -0 / -1 / -9 | Compression tuning | Store only, faster compression, or better compression. |
| -q / -v | Output verbosity | Quiet mode for scripts or verbose mode for diagnostics. |
| -T | Validation | Tests archive integrity. |
| -F / -FF | Recovery attempts | Attempts to fix damaged archives (-FF is more aggressive). |
Flags that are easy to confuse
| Similar flags | Key difference | Typical choice |
|---|---|---|
| -u vs -f | -u adds new files and updates changed files; -f updates only existing archive entries. | Use -u for incremental build artifacts; use -f for strict refresh. |
| -r vs -j | -r walks directories; -j strips stored directory names. | Use -r for reproducible folder structure; use -j only when flattening is required. |
| -i vs -x | -i is allow-list behavior; -x is block-list behavior. | Prefer -i for tighter artifact control in CI. |
| -0 vs -9 | -0 stores without compression; -9 maximizes compression effort. | Use -0 for already-compressed binaries; -9 for text-heavy artifacts. |
| -q vs -v | -q reduces log noise; -v increases diagnostics. | Use -q in stable pipelines and -v when debugging. |
Archive workflow for CI/CD
flowchart TD
A[Select files] --> B[Apply include exclude rules]
B --> C{Archive exists}
C -- no --> D[Create archive]
C -- yes --> E[Update or freshen]
D --> F[Test integrity]
E --> F
F --> G{Integrity ok}
G -- yes --> H[Publish artifact]
G -- no --> I[Repair or rebuild]
Practical command examples
Create a recursive release archive with higher compression
zip -r -9 release.zip dist/
Update an existing archive with only new or changed files
zip -u release.zip dist/
Freshen only files that already exist in the archive
zip -f release.zip dist/
Package selected logs while excluding unwanted files
zip -r logs.zip /var/log -i "*.log" -x "*.gz" "*.old"Code language: JavaScript (javascript)
Read file names from stdin
find dist -type f | zip artifacts.zip -@
Test archive integrity before publishing artifacts
zip -T artifacts.zipCode language: CSS (css)
Best practices and common pitfalls
- Confirm your actual binary and supported flags with
zip -hon the target host. - Quote wildcard patterns (
"*.log") so your shell does not expand them unexpectedly. - Run
-Tintegrity checks in CI after archive creation. - Use
-mcarefully because it deletes source files after archiving. - Avoid
-junless you explicitly want to drop directory paths (name collisions can occur). - Use
-qfor stable pipelines and switch to-vwhen debugging failures.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals