2
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.
2
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.
2
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"