Skip to content
Latchkey

unzip -p: Extract a File to stdout

unzip -p extracts a named file from the archive straight to standard output with no extra text.

Sometimes you only need one file out of a zip, and only to read it. -p pipes it without writing anything to disk.

What it does

unzip -p <archive> <file> writes the contents of the named entry to stdout with no listing, headers, or conversion. It is meant for piping into another command. unzip -c is similar but prints a header line per file and is less suited to clean piping.

Common usage

Terminal
# read one config file without unpacking the archive
unzip -p artifact.zip config/app.json | jq .version
# extract a single file to a known path
unzip -p artifact.zip dist/manifest.txt > manifest.txt

Options

FlagWhat it does
-pExtract to stdout with no extra output
-cExtract to stdout with a header per file
<file>Name of the entry to extract
-x <pattern>Exclude entries from the operation

In CI

unzip -p is ideal for reading a version or manifest out of a built artifact to gate a step, without the cost or cleanup of a full extraction. Because -p emits raw bytes only, it pipes cleanly into jq, grep, or sha256sum. The entry name must match the path stored in the archive exactly.

Common errors in CI

"caution: filename not matched" means the entry path you asked for does not exist in the archive; run unzip -l first to see the exact stored path. Binary files printed to a terminal can garble it; redirect to a file or pipe. "End-of-central-directory signature not found" again means the file is not a valid zip.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →