utility
jq
External JSON processor; tested jq 1.7. -r emits raw strings; -c compact JSON; -n generates without input. Invalid JSON causes parse failure. Keep structured data or use appropriate framing, not shell splitting. Check exit status before consuming output.
Formal Syntax & Structure
bash syntaxbash
jq [OPTIONS] FILTER [FILE...]Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| FILTER | string | Fixed jq expression |
| FILE | path | JSON input file |
Return Value
exit status
External JSON processor; tested jq 1.7. -r emits raw strings; -c compact JSON; -n generates without input. Invalid JSON causes parse failure. Keep structured data or use appropriate framing, not shell splitting. Check exit status before consuming output.
Working Example
Example Snippetbash
printf '%s\n' '{"name":"daily report"}' > item.jsonname=$(jq -er '.name | strings' item.json) || exit 1printf '[%s]\n' "$name"