unzip -o: Overwrite Without Prompting
unzip -o overwrites existing files silently; unzip -n skips any file that already exists.
The default unzip behavior is to ask before overwriting, which has no answer in a non-interactive job and stalls it. -o and -n make the choice up front.
What it does
When a file to be extracted already exists, plain unzip prompts "replace <file>? [y]es, [n]o, [A]ll, [N]one, [r]ename". unzip -o overwrites without prompting; unzip -n never overwrites and keeps the existing file. -o is the usual choice for a clean extraction into a fresh or stale directory.
Common usage
# overwrite existing files, no prompt
unzip -o artifact.zip -d ./out
# never overwrite, keep what is there
unzip -n artifact.zip -d ./outOptions
| Flag | What it does |
|---|---|
| -o | Overwrite existing files without prompting |
| -n | Never overwrite, skip existing files |
| -d <dir> | Extract into the named directory |
| -q | Quiet, suppress the listing |
In CI
Always pass -o (or -n) when extracting into a directory that might already contain files; otherwise the interactive replace prompt has no input and the job hangs until it times out. This is one of the most common silent CI stalls. Even a single pre-existing file triggers the prompt.
Common errors in CI
A job that hangs at the extract step with no further output is almost always unzip waiting on the "replace?" prompt; add -o. If files unexpectedly remain old after extraction, -n is set somewhere and is skipping them. Feeding y to stdin works but -o is cleaner and explicit.