0

When you decompress a gzip archive with gunzip without any arguments, the archive disappears, and you're left with the decompressed file in its place. However, if you use the -c option, the archive remains, and it's decompressed output is only sent to the standard output.

My question is, can I do the same with other archiving or or compression utilities - zip, 7-zip, rar etc? That is, there the initial archive may not disappear when you decompress its contents, but I want to know how I can send the output to standard output instead of a directory

1 Answer 1

0

The formats you mention aren't only compression formats, but also archive formats – they contain multiple files, and the problem is that "stdout" is a simple byte stream with no built-in way to delimit multiple files.

Because of that, the best you can get is an option to output a single file over stdout, for example:

bsdtar xfO MyArchive.zip path/to/important_file.txt > file.txt

I used bsdtar for this example (part of libarchive) because it understands many archive formats including zip and 7-zip.

(You could of course invent a structured format for transferring multiple files over stdio, but... that would be no different from existing 'tar' or 'cpio' archive formats, which do exactly that. You would basically end up making a "zip-to-tar" converter.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .