Home / Alt manpages / zstdcat(1)

  • zstdcat(1)
  • User command
  • linux

Use zstdcat Safely for .zst Files and Shell Pipelines

zstdcat prints the uncompressed contents of a Zstandard file straight to your terminal or the next command in a pipeline. Allow about ten minutes to work through checking, reading, saving and verifying a .zst file, with no decompressed copy left lying around.

The examples use the installed command reported here as zstd 1.5.7. The Debian package metadata on this machine is zstd 1.5.5+dfsg2-2build1.1, so check both the executable and the package when chasing version-specific differences. You need a shell and a readable .zst file; none of the normal examples need elevated privileges, and the commands below only read data or write to named files, never a service or system config.

Checkpoint

By the end, zstdcat FILE.zst prints the original bytes to standard output, and a pipeline consumes them without an intermediate file.

1. Confirm the command you will run

Check the path and version before trusting behaviour you read about on a different host:

$ command -v zstdcat
/usr/bin/zstdcat
$ zstdcat --version
1.5.7
$ dpkg-query -W -f='${Package} ${Version}\n' zstd
zstd 1.5.5+dfsg2-2build1.1

zstdcat is an installed command name for zstd -dcf: decompress, write to standard output, and force the operation. That compact definition is why it's so useful in scripts, and also why you should watch where its output actually lands.

2. Decompress a .zst file to the terminal

Pass the compressed file as the sole argument:

$ zstdcat /path/to/archive.txt.zst
original text appears here

The original compressed file stays exactly where it was. Output goes to standard output, so you can inspect it, redirect it, or hand it to another command. If the content is binary or very large, do not print it straight to a terminal; redirect it to a deliberate destination or use a program that understands the data.

A useful first move is checking metadata without decompressing anything to a file:

$ zstd -l /path/to/archive.txt.zst
Frames  Skips  Compressed  Uncompressed  Ratio  Check  Filename
    1      0        ...          ...       ...   XXH64  archive.txt.zst

Exact sizes and some fields vary by file. -l lists information where it's available; it does not replace an integrity test.

3. Save decompressed output deliberately

Use shell redirection when you actually want a new file:

$ zstdcat /path/to/archive.txt.zst > /tmp/archive.txt
$ test -s /tmp/archive.txt
$ printf 'wrote %s bytes\n' "$(wc -c < /tmp/archive.txt)"
wrote 1234 bytes

Replace the placeholder path and destination with values you've actually checked. The redirection operator truncates an existing destination before zstdcat has even finished running.

Warning

Do not use this form on an important existing file unless overwriting it is intended. Choose a new destination, use set -o noclobber as a shell-level guard, or write to a temporary file and rename it after validation.

If you need the conventional filename derived from archive.txt.zst, use zstd -d instead: it strips the .zst suffix for its output and keeps the source by default. zstdcat is deliberately a stream-to-standard-output command, not a filename-restoration command.

4. Feed compressed data into another command

Because the result is standard output, process it directly:

$ zstdcat /path/to/logs.txt.zst | rg 'ERROR|WARN'
2026-09-28T09:14:02Z WARN cache miss
2026-09-28T09:16:44Z ERROR request failed

The displayed lines are examples; your output depends on the file. The compressed input isn't modified and no uncompressed copy is left behind, which is often the clearest way to search a compressed log.

Standard input works too, as long as it's a pipe rather than an interactive terminal:

$ printf 'one\ntwo\n' | zstd -q -c | zstdcat
one
two

The manpage describes zstdcat as the equivalent of zstd -dcf. The -f part permits standard-output behaviour that ordinary zstd protects more carefully, so keep output directed to a file or pipe when handling data that shouldn't appear on screen.

5. Test integrity without creating output

To verify a compressed file while discarding the decompressed data, use zstd -t:

$ zstd -q -t /path/to/archive.txt.zst
$ printf 'test status: %s\n' "$?"
test status: 0

Status 0 means the test completed successfully. A non-zero status means the file could not be verified: preserve the original and investigate the diagnostic before attempting recovery. This command creates or removes nothing.

For a script, check the status directly rather than parsing human-readable output:

if zstd -q -t -- "$1"; then
    printf '%s\n' 'compressed file passed its integrity test'
else
    printf 'integrity test failed: %s\n' "$1" >&2
    exit 1
fi

The -- marks the end of options. It matters when a path begins with a hyphen, and it makes the intended boundary easier to review on re-read. Validate that the input path is the file you expect before passing it to a script.

6. Diagnose the common failures

  • A missing, unreadable or invalid file produces a non-zero status and a diagnostic on standard error. Do not chase that away with a second -q while troubleshooting: the manpage says the second -q suppresses errors too.
  • An uncompressed file is not automatically a valid Zstandard stream. In particular, the installed command refused /dev/null as a regular file and returned status 1.
  • Do not add -f just to make an input error disappear. In decompression mode, force options can also enable pass-through behaviour for unrecognised formats when output is standard output, which can hide a mistaken input choice.
  • Use zstdcat --help and zstd -V when you need the exact option set of the executable in front of you.
  • Empty output needs a two-step check: first the exit status, then whether the compressed stream legitimately contains no bytes.
  • Pipeline failures can hide upstream. The final command's status may not expose an earlier failure in every shell, so use one with pipeline-status support when that distinction matters.

Done means

  • zstdcat --version identified the executable version you're actually using.
  • You can print or pipe a trusted .zst file without modifying the source.
  • You know shell redirection can overwrite its destination before decompression even finishes.
  • zstd -q -t FILE.zst returns status 0 before you rely on the data.
  • Missing, invalid and unrecognised input are treated as errors, not hidden behind extra quiet flags.