{"id":139,"date":"2026-10-12T12:21:36","date_gmt":"2026-10-12T12:21:36","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2009\/06\/20\/winzip-command-line\/"},"modified":"2026-10-12T12:21:36","modified_gmt":"2026-10-12T12:21:36","slug":"winzip-command-line","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/winzip-command-line\/","title":{"rendered":"zip CLI Cheatsheet for DevOps (Clarifying the Classic \u201cWinZip Commands\u201d Post)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>Originally published on 2009-06-20; fully revised and updated.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide is for engineers who use command-line archiving in build scripts, release packaging, and backup workflows. You will learn the core <code>zip<\/code> options from the original post, how similar flags differ, and safe patterns for CI\/CD usage.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2009\/06\/winzip-command-line.png\" alt=\"zip command-line option list from original post\" width=\"600\" height=\"400\" \/><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What this cheatsheet actually covers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The original article title references WinZip, but the option set shown is the classic <code>zip<\/code> command syntax (for example <code>-u<\/code>, <code>-f<\/code>, <code>-r<\/code>, <code>-T<\/code>). This rewrite keeps that option set and organizes it for practical use. Source post: <a href=\"https:\/\/www.devopsschool.com\/blog\/winzip-command-line\/\">WinZip commands Web References &amp; Cheatsheet<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Command format and default behavior<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">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 <code>-<\/code> to read from standard input. If both zipfile and list are omitted, input is read from stdin and written to stdout.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css language-bash\"><span class=\"hljs-selector-tag\">zip<\/span> <span class=\"hljs-selector-attr\">&#91;options]<\/span> <span class=\"hljs-selector-tag\">zipfile<\/span> <span class=\"hljs-selector-attr\">&#91;list...]<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Core flags by job<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Flag<\/th><th>Best used for<\/th><th>What it does<\/th><\/tr><\/thead><tbody><tr><td>-u<\/td><td>Incremental updates<\/td><td>Adds new files and updates changed files.<\/td><\/tr><tr><td>-f<\/td><td>Freshening existing archives<\/td><td>Updates only files already present in the archive.<\/td><\/tr><tr><td>-d<\/td><td>Cleanup<\/td><td>Deletes matching entries from the archive.<\/td><\/tr><tr><td>-m<\/td><td>Move-then-clean workflows<\/td><td>Moves files into archive and deletes originals.<\/td><\/tr><tr><td>-r<\/td><td>Directory trees<\/td><td>Recurses into subdirectories.<\/td><\/tr><tr><td>-j<\/td><td>Flat archive layout<\/td><td>Stores files without directory paths.<\/td><\/tr><tr><td>-i \/ -x<\/td><td>Inclusion\/exclusion control<\/td><td>Include only matching names or exclude matching names.<\/td><\/tr><tr><td>-0 \/ -1 \/ -9<\/td><td>Compression tuning<\/td><td>Store only, faster compression, or better compression.<\/td><\/tr><tr><td>-q \/ -v<\/td><td>Output verbosity<\/td><td>Quiet mode for scripts or verbose mode for diagnostics.<\/td><\/tr><tr><td>-T<\/td><td>Validation<\/td><td>Tests archive integrity.<\/td><\/tr><tr><td>-F \/ -FF<\/td><td>Recovery attempts<\/td><td>Attempts to fix damaged archives (<code>-FF<\/code> is more aggressive).<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Flags that are easy to confuse<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Similar flags<\/th><th>Key difference<\/th><th>Typical choice<\/th><\/tr><\/thead><tbody><tr><td>-u vs -f<\/td><td><code>-u<\/code> adds new files and updates changed files; <code>-f<\/code> updates only existing archive entries.<\/td><td>Use <code>-u<\/code> for incremental build artifacts; use <code>-f<\/code> for strict refresh.<\/td><\/tr><tr><td>-r vs -j<\/td><td><code>-r<\/code> walks directories; <code>-j<\/code> strips stored directory names.<\/td><td>Use <code>-r<\/code> for reproducible folder structure; use <code>-j<\/code> only when flattening is required.<\/td><\/tr><tr><td>-i vs -x<\/td><td><code>-i<\/code> is allow-list behavior; <code>-x<\/code> is block-list behavior.<\/td><td>Prefer <code>-i<\/code> for tighter artifact control in CI.<\/td><\/tr><tr><td>-0 vs -9<\/td><td><code>-0<\/code> stores without compression; <code>-9<\/code> maximizes compression effort.<\/td><td>Use <code>-0<\/code> for already-compressed binaries; <code>-9<\/code> for text-heavy artifacts.<\/td><\/tr><tr><td>-q vs -v<\/td><td><code>-q<\/code> reduces log noise; <code>-v<\/code> increases diagnostics.<\/td><td>Use <code>-q<\/code> in stable pipelines and <code>-v<\/code> when debugging.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Archive workflow for CI\/CD<\/h2>\n\n\n\n<pre class=\"mermaid\">\nflowchart TD\n    A[Select files] --> B[Apply include exclude rules]\n    B --> C{Archive exists}\n    C -- no --> D[Create archive]\n    C -- yes --> E[Update or freshen]\n    D --> F[Test integrity]\n    E --> F\n    F --> G{Integrity ok}\n    G -- yes --> H[Publish artifact]\n    G -- no --> I[Repair or rebuild]\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Practical command examples<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Create a recursive release archive with higher compression<\/h3>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs language-bash\">zip -r -9 release.zip dist\/<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Update an existing archive with only new or changed files<\/h3>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs language-bash\">zip -u release.zip dist\/<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Freshen only files that already exist in the archive<\/h3>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs language-bash\">zip -f release.zip dist\/<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Package selected logs while excluding unwanted files<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript language-bash\">zip -r logs.zip \/<span class=\"hljs-keyword\">var<\/span>\/log -i <span class=\"hljs-string\">\"*.log\"<\/span> -x <span class=\"hljs-string\">\"*.gz\"<\/span> <span class=\"hljs-string\">\"*.old\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Read file names from stdin<\/h3>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs language-bash\">find dist -type f | zip artifacts.zip -@<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Test archive integrity before publishing artifacts<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css language-bash\"><span class=\"hljs-selector-tag\">zip<\/span> <span class=\"hljs-selector-tag\">-T<\/span> <span class=\"hljs-selector-tag\">artifacts<\/span><span class=\"hljs-selector-class\">.zip<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\">Best practices and common pitfalls<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>Confirm your actual binary and supported flags with <code>zip -h<\/code> on the target host.<\/li><li>Quote wildcard patterns (<code>\"*.log\"<\/code>) so your shell does not expand them unexpectedly.<\/li><li>Run <code>-T<\/code> integrity checks in CI after archive creation.<\/li><li>Use <code>-m<\/code> carefully because it deletes source files after archiving.<\/li><li>Avoid <code>-j<\/code> unless you explicitly want to drop directory paths (name collisions can occur).<\/li><li>Use <code>-q<\/code> for stable pipelines and switch to <code>-v<\/code> when debugging failures.<\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This revised cheatsheet turns the original option dump into a practical guide for day-to-day DevOps use. It explains the most important zip flags, when to use them in automation, and where teams commonly make mistakes.<\/p>\n","protected":false},"author":1,"featured_media":4042,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[49],"tags":[333,824,3145,3152,3143,3144,3151,3148,3147,3150,3149,3146],"class_list":["post-139","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general","tag-command","tag-command-line","tag-list-of-winzip-command","tag-quick-guide","tag-winzip","tag-winzip-command-line","tag-winzip-command-line-cheatsheet","tag-winzip-command-line-guide","tag-winzip-command-line-reference","tag-winzip-command-line-resource","tag-winzip-command-line-tutorial","tag-winzip-command-list"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=139"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/139\/revisions"}],"predecessor-version":[{"id":78988,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/139\/revisions\/78988"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/4042"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}