Skip to content

Instantly share code, notes, and snippets.

@ychsn
Created December 12, 2014 07:11
Show Gist options
  • Select an option

  • Save ychsn/e03d64ef7ba02864781a to your computer and use it in GitHub Desktop.

Select an option

Save ychsn/e03d64ef7ba02864781a to your computer and use it in GitHub Desktop.
get only status code on curl
curl -LI mazgi.com -o /dev/null -w '%{http_code}\n' -s
@espoelstra

Copy link
Copy Markdown

Note that the -I will do a HEAD request which may get a different status code on many services than an actual GET request.

@james4388

Copy link
Copy Markdown

You can do curl -Li mazgi.com -o /dev/null -w '%{http_code}\n' -s
-i work with post too

ghost commented Apr 15, 2020

Copy link
Copy Markdown

@kiraSanti

Copy link
Copy Markdown

Thanks a lot!

@kuboon

kuboon commented Jan 31, 2025

Copy link
Copy Markdown

-I outputs headers. -X HEAD changes method and keep outputs body (=nothing). so you can omit -o part like this

curl -X HEAD -sw '%{http_code}\n' example.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment