Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
up vote 22 down vote accepted

Try this:

curl -vs -o /dev/null http://somehost/somepage 2>&1

That will suppress the progress meter, send stdout to /dev/null and redirect stderr (the -v output) to stdout.

share|improve this answer
Thanks, -s was the key! – Ian Mackinnon Aug 7 '10 at 17:59
@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 Apr 14 '14 at 9:47
curl --fail --silent --show-error > /dev/null

This will suppress the status dialog, but will otherwise output errors to STDERR.

user@host:~# curl > /dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  254k    0  254k    0     0   403k      0 --:--:-- --:--:-- --:--:--  424k

The above outputs the status table when redirecting.

user@host:~# curl --fail --silent --show-error > /dev/null

The above suppresses the status table when redirecting, but errors will still go to STDERR.

user@host:~# curl --fail --silent --show-error > /dev/null
curl: (6) Couldn't resolve host ''

The above is an example of an error to STDERR.

user@host:~# curl -v --fail --silent --show-error > ~/output.txt 2>&1
user@host:~# cat ~/output.txt 
* getaddrinfo(3) failed for
* Couldn't resolve host ''
* Closing connection #0
curl: (6) Couldn't resolve host ''

Just add 2>&1 to the end to redirect STDERR to STDOUT (in this case, to a file).

share|improve this answer

With reference to question 1 (how cURL knows to only display the table when output is redirected), I didn't realise a program could tell its outputs were being directed, but it seems on POSIX systems there is a function isatty which reports whether or not a file descriptor refers to a terminal.

share|improve this answer
Here's a Bash snippet: [[ -p /dev/stdout ]] && echo "stdout is to a pipe"; [[ -t 1 ]] && echo "output to terminal"; [[ ! -t 1 && ! -p /dev/stdout ]] && echo "output redirected" – Dennis Williamson Aug 7 '10 at 20:41

To put real error messages somwhere, you should write strerr into a log file. Something like that:

curl  "" --stderr /var/log/curl_err.log > /dev/null
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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