7-Zip Pipe to Stdout Command Line Switch
This article covers how to force 7-Zip into pipe mode for standard output (stdout) stream processing using the command line. You will learn the exact flag required to write data directly to stdout, how to use it for both decompression and compression workflows, and how to effectively integrate 7-Zip into terminal pipelines.
The command line flag that forces pipe mode for stdout stream
processing in 7-Zip is -so. When appended to a 7-Zip
command, -so instructs the utility to send data directly to
the standard output stream rather than writing files to the disk.
Extracting Archives to Stdout
To decompress files directly to standard output, combine the
e (extract) or x (extract with paths) command
with the -so switch. This is commonly used to pipe
decompressed text or data into other command-line utilities without
generating intermediate files:
7z e archive.7z data.txt -so | grep "target_string"In this example, 7-Zip decompresses data.txt and sends
the uncompressed bytes directly to grep via standard
output.
Creating Archives to Stdout
The -so flag can also direct an entire archive's output
stream to stdout during compression using the a (add)
command. This allows you to redirect the compressed stream over a
network, to another program, or into a redirected file:
7z a -txz -so dummy.xz large_file.tar > output.tar.xzWhen writing archive streams to stdout, ensure that the chosen
archive format supports sequential stream writing. Streaming formats
such as .xz, .gzip, and .bzip2
work natively with -so. Formats like standard multi-file
.7z or .zip often require file seeking to
write directory metadata, which can restrict certain stdout compression
operations.
Stream Management and Clean Output
When -so is specified, 7-Zip automatically suppresses
standard informational banners from the stdout channel to
protect data integrity, routing progress and diagnostics to
stderr instead. To suppress operational messages completely
and ensure an entirely clean stream, combine -so with the
-bso0 switch:
7z e archive.7z file.bin -so -bso0 > extracted_file.bin