I need to extract an tar.gz archive I downloaded with curl into STDOUT and use the STDOUT as STDIN for zipping the files again.

curl -L someURL | tar xz --strip-components=1 -O| zip -r test.zip

gives me enter cocurl: (23) Failed writing bodyde here.

The problem is produced by the -O flag of tar.

1 Answer 1


Your're missing a minus sign before the -O and missed the minus argument for zip:

curl -L someURL | tar xzf - -O | zip test.zip - works on my system with

  • curl 7.26.0
  • tar (GNU tar) 1.26
  • Zip 3.0
  • okay this seems to work better, but the zip command does not get the input from STDOUT
    – Flatron
    Sep 15, 2014 at 15:17
  • no not working, tar says - not found in the archive
    – Flatron
    Sep 15, 2014 at 15:19
  • @Flatron have you tried a copy and paste of what @Jan suggested? The venerable tar hasn't changed its argument syntax in decades.
    – zwets
    Sep 15, 2014 at 18:28
  • I did a copy and paste and the command itself is working, but the zip is only containing a file - that is a zip of the whole stdout output binary. So not really useful.
    – Flatron
    Sep 15, 2014 at 19:15
  • You might be doing something else or have a different version of tar, curl or zip - on the machines I have access to, the zip is a normal zip archive with the compressed files inside.
    – Jan
    Sep 15, 2014 at 19:21

You must log in to answer this question.

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