Interview Prep/Shell Scripting/find, xargs, jq and yq

What is `jq` and what are the filters you use every day?

BeginnerConceptfind, xargs, jq and yq
Answer

jq is a command-line JSON processor.

jq '.' file.json                        # pretty-print and validate
jq -r '.metadata.name' pod.json         # raw string, no quotes
jq '.items[] | .metadata.name'          # iterate an array
jq '.items | length'                    # count
jq '.items[] | select(.status.phase != "Running") | .metadata.name'
jq -r '.Reservations[].Instances[] | [.InstanceId, .State.Name] | @tsv'
jq '.spec.replicas = 3' deploy.json     # modify
jq -e '.ready == true' status.json      # exit 1 if false or null

-r (raw output) is what you want when the value feeds another command.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on find, xargs, jq and yq