How to Print RAR Files to Stdout with Unrar
This guide explains how to display the contents of a file stored
inside a RAR archive directly to standard output (stdout) using the
unrar command-line utility. By routing file contents to
stdout instead of extracting them to the disk, you can inspect files
instantly, pipe data into other command-line tools, or stream contents
without consuming extra storage space.
The Print Command:
unrar p
The command used to output file contents directly to standard output
is p (print).
The basic syntax is:
unrar p archive.rar [filename]If you do not specify a filename, unrar will print the
contents of every file in the archive sequentially to standard
output.
Suppressing Headers and Metadata
By default, unrar displays a copyright banner,
processing details, and archive metadata alongside the file contents.
When piping the output to another program, these extra messages can
corrupt your data stream.
To ensure only the actual file content is printed, use the
-inul (inhibit messages) switch:
unrar p -inul archive.rar document.txtCommon Usage Examples
Viewing a File in a Pager
To read a text file inside an archive without creating an extracted copy:
unrar p -inul archive.rar notes.txt | lessSearching Inside an Archived File
To search for a specific term inside an archived file using
grep:
unrar p -inul archive.rar server.log | grep "ERROR"Working with Password-Protected Archives
If the archive is encrypted, pass the password directly using the
-p switch:
unrar p -inul -pSecretPassword archive.rar secure_data.csv