What is `yq`, and why does "which yq" matter?
IntermediateConceptfind, xargs, jq and yq
Answer
Two different tools share the name:
- mikefarah/yq (Go, v4): jq-like syntax for YAML, JSON, XML, TOML, with in-place editing (
-i) that preserves comments. This is the common one in DevOps. - kislyuk/yq (Python): a wrapper that converts YAML to JSON and runs real
jq.
yq --version # "yq (https://github.com/mikefarah/yq/) version v4.x"
yq '.spec.replicas' deploy.yaml
yq -i '.spec.replicas = 3' deploy.yaml
Pin the exact tool and version in CI images, because scripts written for one fail with the other (and yq v3 syntax yq r file key fails in v4).
More on find, xargs, jq and yq
What are the most useful `find` predicates for operations work?BeginnerWhat is the difference between `-exec cmd {} \;`, `-exec cmd {} +` and `-delete`?IntermediateHow does `find` evaluate `-o` (OR) and why do you need parentheses?AdvancedWhat does `xargs` do, and which flags matter?IntermediateWhy is `find | xargs rm` dangerous and what is the safe form?IntermediateWhat is `jq` and what are the filters you use every day?Beginner