How to Extract RAR to Stdout Using Unrar
Extracting files directly to standard output (stdout) allows you to
process compressed data in memory, stream it to other utilities, or
redirect it without writing temporary files to disk. The standard
non-free unrar utility fully supports this behavior using
the p (print) command combined with flags that suppress
extraneous logging messages.
The Basic Command
To send the contents of a file inside an archive directly to stdout,
use the p command:
unrar p archive.rar file_inside.txtIf you do not specify an individual file name, unrar
will dump the contents of every file in the archive sequentially into
the stdout stream.
Suppressing Console Messages
By default, unrar outputs diagnostic banners, version
details, and extraction status messages to the console alongside the
file content. If you are piping binary data or redirecting output to a
new file, these banners will corrupt the stream.
To disable all informational messages and output only the raw file
data, include the -inul (inquire null / disable messages)
switch:
unrar p -inul archive.rar target_file.bin > extracted_file.binPiping to Other Commands
Streaming to standard output is particularly useful for piping extracted content directly into other command-line tools without intermediate disk storage:
Inspect text files with a pager:
unrar p -inul archive.rar log.txt | lessSearch inside a compressed file:
unrar p -inul archive.rar data.csv | grep "search_term"Compute a checksum without extraction:
unrar p -inul archive.rar disc.iso | sha256sum
Handling Password-Protected Archives
If the archive requires a password, supply it via the
-p<password> switch directly adjacent to the flag
without a space, ensuring the process remains fully non-interactive:
unrar p -inul -pSecretPassword archive.rar file.txtAlternative: Using 7-Zip
If unrar is unavailable on your system,
p7zip (via the 7z command) offers the exact
same capability using the -so (standard output) switch:
7z e -so archive.rar target_file.bin > extracted_file.bin