Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

22
  • 85
    -w "%{http_code}" is the bit that prints the status code. You can add a newline or two in there to separate the code from the body (-w "\n\n%{http_code}\n") Commented Jan 11, 2014 at 8:33
  • 19
    Wow, this /dev/null thing even works in the Windows version of curl that I'm using.
    – Uwe Keim
    Commented Jan 30, 2015 at 6:53
  • 4
    I believe this downloads the entire file even though it all goes to /dev/null, so not ideal for checking the status code for huge files. httping -c 1 -s -G -m issues a GET and doesn't download the whole file, although I realise this question is specifically about curl.
    – RomanSt
    Commented Dec 13, 2015 at 23:59
  • 87
    FYI: -s = Don't show download progress, -o /dev/null = don't display the body, -w "%{http_code}" = Write http response code to stdout after exit.
    – Ajedi32
    Commented Jul 19, 2016 at 16:59
  • 3
    Are the quotes around the "%{http_code}" required ?
    – Hakan Baba
    Commented Mar 13, 2018 at 18:52