Why "curl -s" and "curl" give the same result?

On the command line, if I type

curl -s 

or

curl 

I get the same result:

{ "args": {}, "headers": { "Accept": "*/*", "Host": "httpbin.org", "User-Agent": "curl/7.63.0", "X-Amzn-Trace-Id": "Root=1-5eb2c764-3e67fbd6113ee4c0e5bccd8a" }, "origin": "109.11.151.178", "url": ""
}

But if I use a pipeline to use the result of curl, for example, I type this:

curl | grep -E '\d+'

Then I get:

 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed
100 255 100 255 0 0 1237 0 --:--:-- --:--:-- --:--:-- 1231 "User-Agent": "curl/7.63.0", "X-Amzn-Trace-Id": "Root=1-5eb2c935-af183e03612a957bc5d1b48b" "origin": "109.11.151.178",

If I used the "-s" option for curl, the result of the pipeline is different:

 "User-Agent": "curl/7.63.0", "X-Amzn-Trace-Id": "Root=1-5eb2c990-5b0d5bb00b3c8aff7acf8d79" "origin": "109.11.151.178",

After some serach on the Internet, I got to know that "-s" option of curl won't print out the progress meter:

Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute. It will still output the data you ask for, potentially even to the termi- nal/stdout unless you redirect it.

  • But where does the "progress meter" come from ?
  • Why the "progress meter" doesn't show when I use "curl" or "curl -s" ?
  • Why does it occur when a pipeline is used ?

1 Answer

From man curl:

PROGRESS METER
curl normally displays a progress meter during operations, indicating the amount of transferred data, transfer speeds and estimated time left, etc.

[...] if you invoke curl to do an operation and it is about to write data to the terminal, it disables the progress meter as otherwise it would mess up the output mixing progress meter and response data.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like