Use zstdcat Safely for .zst Files and Shell Pipelines
You will use zstdcat to print the uncompressed contents of a Zstandard file, feed that output into another command, and check a file's integrity without creating a decompressed copy. 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 package when investigating version-specific differences.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about ten minutes. You need a shell and a readable .zst file. None of the normal examples needs elevated privileges. The commands below read data or write only to named files; they do not change a service or system configuration.
Checkpoint
By the end, zstdcat FILE.zst will print the original bytes to standard output, and a pipeline will consume them without an intermediate file.
1. Confirm the command you will run
Check the path and version before relying on behaviour from 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 explains why it is useful in scripts, but also why you should treat its output destination carefully.
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 remains in place. Output goes to standard output, so you can inspect it, redirect it, or pass it to another command. If the content is binary or very large, do not print it to a terminal. Redirect it to a deliberate destination or use a program that understands the data.
A useful first check is to inspect metadata without decompressing 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. The -l option lists information where it is available; it does not replace an integrity test.
3. Save decompressed output deliberately
Use shell redirection when you 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 have checked. The redirection operator will truncate an existing destination before zstdcat has finished. Warning: do not use this form for an important existing file unless overwriting it is intended. Choose a new destination, use set -o noclobber for 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 removes the .zst suffix for its output and keeps the source by default. zstdcat is intentionally 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 is not modified, and no uncompressed copy is left behind. This is often the clearest approach for searching a compressed log.
Standard input works when it is a pipe rather than an interactive terminal. For example:
$ 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. Keep the output directed to a file or pipe when handling data that should not appear on screen.
5. Test integrity without creating output
To verify a compressed file while discarding 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 does not create or remove files.
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 is useful when a path begins with a hyphen, and it makes the intended boundary easier to review. Validate that the input path is the file you expect before passing it to a script.
6. Diagnose the common failures
A missing file, an unreadable file, or invalid compressed data produces a non-zero status and a diagnostic on standard error. Do not suppress errors with -q twice while troubleshooting: the manpage says that the second -q suppresses errors too.
An ordinary 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 simply 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. If output is unexpectedly empty, first check the exit status, then check whether the compressed stream legitimately contains no bytes. If a pipeline fails, remember that the final command's status may not expose an earlier failure in every shell; use a shell with pipeline-status support when that distinction matters.
Done means
zstdcat --versionidentified the executable version you are using.- You can print a trusted
.zstfile or pipe it into a reader without modifying the source. - You know that shell redirection can overwrite its destination before decompression finishes.
zstd -q -t FILE.zstreturns status 0 before you rely on the data.- Missing, invalid, and unrecognised input are treated as errors rather than hidden with extra quiet flags.