-3

What is the correct way to curl to stdout, then untar (a zip file in that case) to a specific directory?

This failed:

curl URL | tar -x > /path

So I thought of this which also failed:

curl URL | tar -x > /path
Arcticooling
  • 1
  • 12
  • 44
  • 103
  • Why would you untar a zip file rather than unzipping it? Or is it a gzip file containing a tar archive? gzip and zip are two different things. – DopeGhoti Jan 30 '18 at 19:53
  • `curl URL | unzip > /path` fails. – Arcticooling Jan 30 '18 at 19:57
  • `unzip` _cannot_ unzip from standard input, as stated in its manual page. You will have to write to a temporary file, `unzip` it, and delete the file. – DopeGhoti Jan 30 '18 at 19:58
  • That's why I contemplated `tar`... It's not possible at all with `tar`? I really don't know. – Arcticooling Jan 30 '18 at 20:04
  • `tar` doesn't speak PKZip. – DopeGhoti Jan 30 '18 at 20:06
  • Oh, crap... Do you know a good fast alternative than? Please share a way if you know one. The ultimate goal is to download, extract, and redirect all in one line, shortest as possible. – Arcticooling Jan 30 '18 at 20:11
  • Re. the above duplicate ([How to redirect output of wget as input to unzip?](https://unix.stackexchange.com/q/2690/86440)), see in particular the `jar` trick. As long as you don’t need to preserve permissions, it should work for you: it can extract from standard input. – Stephen Kitt Jan 30 '18 at 22:13

1 Answers1

0

Duplicate of How to redirect output of wget as input to unzip? (wget and curl are interchangeable in this context). Please see this answer. Replicating it here:

wget URL -O path/temp.zip; unzip -d path path/temp.zip; rm path/temp.zip

Replace URL and path accordingly.

thiagowfx
  • 1,221
  • 11
  • 20