Dev.to
7/11/2026
The original title is "jq in Shell Scripts: The Small Things That Trip You Up"
Original: jq in Shell Scripts: The Small Things That Trip You Up
Short summary
A practical guide to jq edge cases in shell scripts, covering null handling with the // operator, array filtering with select(), and distinguishing empty arrays from null results. Includes defensive patterns like jq -e for exit-code-based null detection and wrapper checks for missing keys. Aimed at sysadmins and developers processing JSON in production pipelines.
- •Use jq's // operator to provide defaults for null or missing fields
- •Empty arrays from select() are not null — scripts must distinguish the two
- •jq -e returns exit code 5 for null output, enabling shell-level error handling
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



