Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Hi I'm trying to see if a server I'm running has been stopped (if it has, it returns a 502 Bad Gateway message.)

So I tried to do this :

curl http://MY_URL | grep "502"

The curl part returns what I expect it to.

But when I pipe it into grep, grep seems to be adding a bunch of headings :

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
113   682  113   682    0     0   230k      0 --:--:-- --:--:-- --:--:--  666k

These aren't in the output from curl. And grep on ordinary text files doesn't add them. So why are they getting added to curl piped through grep?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

That output is from curl. It's added when standard output is not a terminal, and in some other circumstances. Use curl -s if you don't want to see it.

share|improve this answer
    
Weird behaviour though, isn't it? To produce different output depending on whether it's going to the terminal or stdout. I thought unix tools were meant to ignore that kind of context. –  interstar Mar 18 '13 at 0:43
    
Don't ask me, I didn't write it. –  Michael Hampton Mar 18 '13 at 0:45
add comment

It is not a grep proble, but a curl feature. Try it with cat and you will see.

You can deal around it with -s (suppress the progress meter), an -o output .

Man curl for more.

share|improve this answer
add comment

Your Answer

 
discard

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.