How can I return 0 when the response status is 200?
Right now I'm able to get the status, e.g., 200 with the following command:
curl -LI http://google.com -o /dev/null -w '%{http_code}\n' -s
But I need to turn this 200 in a return of 0.
How can I achieve this?
I tried the following command, but it doesn't return:
if [$(curl -LI http://google.com -o /dev/null -w '%{http_code}\n' -s) == "200"]; then echo 0
It looks like you need some spaces and a fi
. This works for me:
if [ $(curl -LI http://google.com -o /dev/null -w '%{http_code}\n' -s) == "200" ]; then echo 0; fi