`curl -O` stores an empty file though `wget` works well
9,842
You've missed to follow redirections with curl
as the URL endpoint is redirected (301) to another endpoint (https://s3.amazonaws.com/logzio-elk/apache-daily-access.log
); sending a request with HEAD method (-I
) to the specified URL:
% curl -LI https://logz.io/sample-data
HTTP/1.1 301 Moved Permanently
...
...
Location: https://s3.amazonaws.com/logzio-elk/apache-daily-access.log
...
HTTP/1.1 200 OK
...
...
Server: AmazonS3
As curl
does not follow HTTP redirections by default, you need to tell curl
to do so using the -L
/--location
option:
curl -LO https://logz.io/sample-data
As wget
follows redirections by default, you're getting to the eventual URL with wget
as-is.
Related videos on Youtube
Author by
user3523935
Updated on September 18, 2022Comments
-
user3523935 over 1 year
I have tried to download a file from
https://logz.io/sample-data
.curl -O https://logz.io/sample-data
However, it just returns an empty file named
sample-data
.In contrast to
curl
, however,wget
works well returning a file containing proper contents.wget https://logz.io/sample-data
What have I missed with
curl
?