Capture HTTP status for shell scripts.
Section: Config Files and Scripting
Script-safe status check
bash
bash
status=$(curl -s -o /tmp/resp.json -w '%{http_code}' https://api.example.com/health)\n[ "$status" -eq 200 ] && echo ok || echo failExplanation
A common automation pattern: body to file, status to shell variable.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Config Files and Scripting
Example curl config file
Store headers, auth, and URL in a reusable config file.
Send request body from a file
Post the contents of a local file as the request body.