A more specific way to print out just the HTTP status code is something along the lines of:
curl -s -o /dev/null -w "%{http_code}" http://www.example.org/
A lot easier to work with in scripts, as it doesn't require any parsing :-)
The parameter -I
might be added to improve response load performance. This will change the call to a HEAD
call which will fetch response overhead only, without the body.
Note: %{http_code}
returns on first line of HTTP payload (available variables for the -w
option on the curl
documentation page)
i.e.:
curl -s -o /dev/null -I -w "%{http_code}" http://www.example.org/