Something that came up whilst writing some scripts was how to get the response code back from curl. I’m posting this here in case it’s useful!
curl -w %{http_code} -s "http://www.google.com" -o /dev/null
Breaking this down;
-w, –write-out <format>
Defines what to display on stdout after a completed and successful operation. We’re just getting http_code but there are other options if you take a look at the man page.
-s, –silent
Silent or quiet mode. Don’t show progress meter or error messages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it.
-o, –output <file>
Write output to <file> instead of stdout. This is just to mute the rest of the output.