Skip to content
Latchkey

unzip -t: Test an Archive for Corruption

unzip -t reads every entry and checks its CRC, reporting whether the archive is intact, without writing files.

After a download or before a deploy, testing an archive catches corruption early. -t verifies every entry CRC and exits non-zero on any failure.

What it does

unzip -t decompresses each entry in memory and compares it against the stored CRC-32, printing "No errors detected in compressed data" when all pass. It does not extract files. The exit code is non-zero if any entry fails, so it works as a gate.

Common usage

Terminal
# verify a downloaded artifact before using it
unzip -t artifact.zip || echo "archive is corrupt"
# quiet test, only show failures
unzip -tq artifact.zip

Options

FlagWhat it does
-tTest archive integrity (check every CRC)
-tq / -t -qTest quietly, report only problems
-lList instead of test
-vVerbose listing

In CI

Run unzip -t right after downloading an archive and before extracting or deploying it, so a truncated or corrupt download fails the build with a clear message rather than a confusing downstream error. The non-zero exit on failure makes it a clean gate with || or set -e.

Common errors in CI

"End-of-central-directory signature not found" means the file is truncated, corrupt, or not a zip at all (a common cause is a saved HTML error page or an interrupted download). "bad CRC" on an entry means that file is damaged. "cannot find zipfile directory" is the same family. If -t passes but extraction fails, the issue is on the filesystem side (permissions or disk space), not the archive.

Related guides

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