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.

I need to curl/wget a page and make sure it returned a particular value (else return 1), something like this:

curl http://example.com/something/run | grep -e '^success!$' || return 1

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

share|improve this question

1 Answer 1

up vote 0 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 "http://example.com" 2> /dev/null | grep -qci -e 'something' && echo "yay"
share|improve this answer

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.