Skip to content

.tip

· one of the small things

Stop parsing JSON with grep, use jq

A shell script with grep '"status"' in it is one whitespace change away from breaking. jq reads the actual structure.

curl -s https://api/status | jq -r '.services[] | select(.healthy == false) | .name'

-r prints raw strings instead of quoted ones, which is what you want when the output feeds into another command.

shell