jq CLI Recipes/Use jq exit status

Set shell exit code based on jq result.

Section: Arguments and Shell Integration

Use jq exit status

bash
bash
echo '{"healthy":true}' | jq -e '.healthy' > /dev/null
Explanation

`-e` is excellent for shell conditions and CI checks.

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 Arguments and Shell Integration
Pass string variable
Inject a shell string into a jq program.
OpenIn sheetbashsame section
Pass JSON value
Inject a JSON literal like a number, array, or object.
OpenIn sheetbashsame section
Read another JSON file into variable
Load a JSON file into jq as an array of documents.
OpenIn sheetbashsame section
Read one JSON file into variable
Load one JSON document into a jq variable.
OpenIn sheetbashsame section
Convert env vars into JSON object
Build JSON from shell variables.
OpenIn sheetbash2 tag match
Pretty-print JSON API response
Format a JSON HTTP response from curl.
OpenIn sheetbash1 tag match