69
13
I'm trying to print just the verbose sections of a cURL request (which are sent to stderr
) from the bash shell.
But when I redirect stdout
like this:
curl -v http://somehost/somepage > /dev/null
Some sort of results table appears in the middle of the output to stderr
:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
Followed by this near the end:
{ [data not shown]
118 592 0 592 0 0 15714 0 --:--:-- --:--:-- --:--:-- 25739
Which makes the response headers less readable.
I don't see this text when not redirecting.
Another way to see the effects:
Table doesn't appear:
curl -v http://somehost/somepage 2>&1
Table appears:
curl -v http://somehost/somepage 2>&1 | cat
1) How come this shows up only with certain types of redirects?
2) What's the neatest way to suppress it?
Thank you
34Thanks,
-s
was the key! – Ian Mackinnon – 2010-08-07T17:59:30.267but why does the progress bar only appear in the first place when redirecting? I ran into this same issue when piping the output of
curl
tojq
. No progress bar without piping tojq
, then when piping tojq
I have to go back and add-s
. – sixty4bit – 2019-07-29T17:54:05.427@sixty4bit: That's a design choice the developers made. The program can detect when its
STDOUT
isn't a tty. When output is not being piped, you don't want progress information to be interspersed with normal output, which you can see and have some idea of progress. When output is redirected or piped, you can't see it so you have no gauge for progress - unless the progress bar is turned on. – Paused until further notice. – 2019-07-29T20:18:46.2776@IanMackinnon Note that with
-s
but without-v
you will not see errors such as failure to connect. For that you should also add-S
(or--show-error
) as in mhoydis's answer. – Artyom – 2014-04-14T09:47:56.250