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 need to curl/wget a page and make sure it returned a particular value (else return 1), something like this:

curl | grep -e '^success!$' || return 1

Which flags should I use in curl or wget? It's not working.

share|improve this question
up vote 1 down vote accepted

You need to suppress the error output from curl with 2> /dev/null. Then, pipe the output to grep -qc, which will suppress normal output and just display the count of matches.

You can then proceed as usual.

curl "" 2> /dev/null | grep -qci -e 'something' && echo "yay"
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.