Getting curl to output HTTP status code

curlhttpstatus

I'm using curl at the command line on Linux to issue HTTP requests. The response bodies are printed to standard out, which is fine, but I can't see from the man page how to get curl to print the HTTP status code from the response (404, 403 etc). Is this possible?

Best Answer

This should work for you if the web server is able to respond to HEAD requests (this will not perform a GET):

curl -I http://www.example.org

As an addition, to let cURL follow redirects (3xx statuses) add -L.

Related Question