7zip: how to extract to std output?

30

5

I have 7z 4.65 and am trying to extract a single file to standard output. The 7z command-line help says -so is the command-line parameter to extract to standard output, but when I try this:

>>> 7z e -so dist\dlogpkg.jar META-INF/MANIFEST.MF

7-Zip 4.65  Copyright (c) 1999-2009 Igor Pavlov  2009-02-03
Error:
I won't write data and program's messages to same terminal

how can I fix this? There doesn't seem to be a command line param to suppress the normal 7z stdout messages.

(edit: the equivalent operation in "unzip" would be

unzip -p dist\dlogpkg.jar META-INF/MANIFEST.MF

which works fine. But I'd like to use 7z for various reasons.)

Jason S

Posted 2010-06-03T15:59:33.767

Reputation: 5 983

Answers

18

pipe it to another program such as

  • tee
  • less
  • more

i think tee comes closest to what you want, it drops the 7z stuff and just gives you the content.

% 7z e -so dist\dlogpkg.jar META-INF/MANIFEST.MF | tee

akira

Posted 2010-06-03T15:59:33.767

Reputation: 52 754

@akira maybe he wanted to pipe the output to another program – beppe9000 – 2015-09-30T11:48:52.693

@Andy: why OP wanted to pipe to stdout was never a question. – akira – 2015-09-30T13:22:03.110

Is there any reason in particular why you think tee is better in this situation than less? – Andy – 2010-06-03T17:51:15.793

Odd. "less" and "tee" do what I expect, but "more" leaves in the 7z stuff.... bizarre! why does it do this? – Jason S – 2010-06-03T18:01:09.250

@Andy: "tee" does even less than "less" .. no scrolling back etc. it just lets the bytes through and not a thing more. – akira – 2010-06-03T20:51:15.420

@JasonS Because less is more – William T Froggard – 2017-07-07T00:32:52.247

8

On Windows, 7z x -so my_file.zip 2> NUL doesn't work, but redirection to a real file helps:

7z x -so my_file.zip 2> _garbage.txt

ansgri

Posted 2010-06-03T15:59:33.767

Reputation: 363

7

I was also trying to figure this out. This got me what I wanted:

7z x -so my_file.zip 2> /dev/null

Jeremy Miller

Posted 2010-06-03T15:59:33.767

Reputation: 71

1Windows equivalent 7z x -so my_file.zip 2> NUL doesn't work: somehow also redirects data to null. – ansgri – 2012-12-26T11:15:22.200