What I have tried:

  1. cat archive.rar | unrar x -
  2. cat archive.rar | unrar x /dev/stdin
  3. cat archive.rar | 7z x -
  4. cat archive.rar | 7z x -si
  5. cat archive.rar | 7z l -si

The unrar doesn't recognise the - filename altogether and says Seek error in the file /dev/stdin for /dev/stdin

7z complains Error: : E_NOTIMPL

So, is this possible? Any other tool to read the RAR archives from another program's STDOUT?

(Note: of course, the cat here is just for an example, the archive files can actually be retrieved with wget or something similar, but they are not local.)


Solution 1:

FIFO (first-in-first-out) streams like /dev/stdin are not seekable, and that's apparently what both unrar and 7z needs to be able to process the files (unlike e.g. tar and gzip that both work with streams).

If using the RAR format and streaming from stdout are both important to you, I would first investigate whether the RAR format will work with streams at all.

Otherwise, for a workaround; you can make a script like this:

#!/bin/bash
cat /dev/stdin > tmp.rar
unrar x tmp.rar
rm tmp.rar

And then run it like so: cat archive.rar | ./script.sh