jq and yq
jq and yq, query and edit JSON and YAML from the command line.
jq filters JSON: pick fields, select items, reshape the output. yq does the same for YAML with the same expression language, and converts between YAML and JSON. Together they read every -json output of zc-workstation and its YAML config.
On the workstation
-
Installed by the
jqandyqformulae.yqis Mike Farah’s Go version. -
ghtakes the same expressions with--jq, so a GitHub query needs no pipe.
Keys and commands
| Key or command | Does |
|---|---|
|
Pretty-print JSON |
|
Print a field of every item, without quotes |
|
Keep the items that match |
|
Merge two JSON files, the second winning |
|
Query YAML |
|
Edit YAML in place |
|
Convert YAML to JSON |
With zc-workstation
The targets that are not fully in place:
$ zc-workstation status -json | jq -r '.[] | select(.in_place < .declared) | .summary'
41 of 43 dotfiles in place
Each planned change on one line:
$ zc-workstation plan -json | jq -r '.actions[] | "\(.op) \(.target) \(.resource)"'
UPDATE macos com.apple.finder FXPreferredViewStyle
The targets that run on Linux:
$ yq '.targets[] | select(.os[0] == "linux") | .name' zc-workstation.yaml
apt
Edit this page Last updated