Printing the HTTP status code in curl

This should be easier, but here it is for reference:

curl -w “status: %{http_code}\n”

One thought on “Printing the HTTP status code in curl

  1. If you don't mind the extra output, you can make a `HEAD` request with the `-I` flag:$ curl -I http://www.google.comHTTP/1.1 200 OKDate: Wed, 30 Jul 2014 00:16:24 GMTExpires: -1Cache-Control: private, max-age=0Content-Type: text/html; charset=ISO-8859-1Set-Cookie: PREF=ID=96058df09db9116e:FF=0:TM=1406679384:LM=1406679384:S=GOtsYK2SjRJbWOm9; expires=Fri, 29-Jul-2016 00:16:24 GMT; path=/; domain=.google.comSet-Cookie: NID=67=WGFiJdtB0dcBEjbSqkodeaXkwm2aUcWocmXh6zw2fy5oBuk8a_eiS4YucOmXmKGJf2QHj1pjNjkygtWVybpt3sAM5KbOSkKDZrJjUfa2dAm_j_H9T5LTuIsMFpL2Duv-; expires=Thu, 29-Jan-2015 00:16:24 GMT; path=/; domain=.google.com; HttpOnlyP3P: CP=\”This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info.\”Server: gwsX-XSS-Protection: 1; mode=blockX-Frame-Options: SAMEORIGINAlternate-Protocol: 80:quicTransfer-Encoding: chunked

    Like

Comments are closed.