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?


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.

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.