Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

So I have a curl that is piped to a grep and a sed. Where would I apply the >/dev/null 2>&1 ?

curl www.site.com | grep stuff | sed "other stuff"

At the very end or after the curl?

share|improve this question
As I said, I want to silence the curl by directing its stdout output and stderr output to /dev/null. –  tzippy Jul 26 '12 at 22:13
add comment

2 Answers

Please be more specific what is the purpose of the command. I guess you want to use

curl -s www.site.com

to prevent the progress indication and other stuff. -s will perform the same action but silently

If you absolutely have to use >/dev/null 2>&1 i think i would redirect curl output to the file

curl www.site.com -o file.txt >/dev/null 2>&1
cat file.txt | grep stuff | sed "other stuff"   
share|improve this answer
Thanks. That's what I wanted to achieve. So out of curiousity: Where would the >/dev/null 2>&1 go? –  tzippy Jul 26 '12 at 22:17
if you do curl www.site.com >/dev/null 2>&1 | grep stuff | sed "other stuff" the grep will receive nothing. If you do curl www.site.com >/dev/null 2>&1 | grep stuff | sed "other stuff" >/dev/null 2>&1 you will not see anything. –  mnmnc Jul 26 '12 at 22:21
add comment

Just explained a bit closer: >/dev/null redirects SDTOUT (standard output) to the "black hole", and 2>&1 appends STDERR (standard error output) to STDOUT so it also goes to Nirvana. This leaves nothing to display: normal output as well as errors are gone. So what you probably may want could be

curl -s www.site.com 2>/dev/null | grep stuff | sed "other stuff"

i.e. not redirecting STDOUT, just suppressing STDERR and telling curl to only show the indended content, then piping that to grep and finally to sed.

Take care to not introduce spaces between "2>", or the 2 would rather be interpreted as additional parameter to curl ;)

share|improve this answer
add comment

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.