9

I am using curl to download a file using the following command.

curl -O https://s3.amazonaws.com/dl4j-distribution/GoogleNews-vectors-negative300.bin.gz

I want to unpack it in a pipeline in the following way. curl -O url | unpack it and store it here in current directory

I used the following command, however, it does not work. I get"gzip: stdin: not in gzip format" Any ideas how can I achieve this?

curl -O https://s3.amazonaws.com/dl4j-distribution/GoogleNews-vectors-negative300.bin.gz | gunzip

I simply want to achieve something like this:

download somecompressedfile | decompress it.

or as simple as this:

ls | grep test.gz | decrompess test.gz

1 Answer 1

10
curl -o - https://s3.amazonaws.com/dl4j-distribution/GoogleNews-vectors-negative300.bin.gz | gunzip > ./GoogleNews-vectors-negative300.bin

Explanation:
- represents the standard output. The standard output is what gets redirected by piping with |.
From man curl:

Specifying the output as '-' (a single dash) will force the output to be done to stdout.

2
  • Can you tell me what the - does after -o? seems like that does trick?
    – nickg
    Jul 27, 2017 at 15:31
  • Somehow the above didn't work for me, I had to use this -L as well curl -L -o - <URL> | gunzip > <file_name>
    – vikas027
    Aug 6, 2021 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.