Getting HTTP Status Codes from the Command Line

How you can go about getting HTTP status codes from your terminal

In my post about HTTP Status Codes and their usefulness for SEO I briefly mentioned a unix command you can run to retrieve the status code for any URL;

curl -I tosbourn.com
HTTP/1.1 200 OK
....

I wanted to talk about this in a bit more depth. I have recorded a video if you prefer watching SEO stuff to reading it.

The command we end up using is;

curl -Is tosbourn.com | head -1 | awk '{print $2}'

What this is saying is;

  • Give me just the head information from the request (curl -I)
  • Don’t give me feedback when retrieving the request (curl -s)
  • I only care about the first row of whatever is returned (head -1)
  • I only care about the second column of what is returned (awk '{print $2}')

Recent posts View all

Web DevProductivity

Keeping on top of website updates

Learn what website updates are, what they entail, why they are important, and how we can help

Freelancing

Getting the most out of your agency

Here are some tips based on years of working with, for, and as an agency on how to get the most out of any work you do.