Date created: Monday, July 17, 2023 12:01:03 PM. Last modified: Sunday, October 27, 2024 4:49:52 PM
'yq' - Notes
snap install yq
Output multiple fields:
$ yq '.interdotlink.name, .interdotlink.platform' r1-pop1.yaml
r1-pop1
eos
Filter for fields with a specific value:
$ yq '.name, .platform|select(.platform == "eos")' *.yaml
r1-pop1
---
r2-pop1
---
r1-pop2
---
r2-pop2
---
Remove the YAML header:
$ yq -N '.name, .platform|select(.platform == "eos")' *.yaml
r1-pop1
r2-pop1
r1-pop2
r2-pop2
yq doesn't have if else support right now. One can chain select statements instead (to exclude lab devices and inactive devices):
$ yq -N '.[] | select(.name != "r*-lab") | select(.platform == "eos") | select(.status == "active") | .name'
Previous page: 'yt-dlp' - Notes
Next page: Bond Interface