Difference between revisions of "yq parser"

From thelinuxwiki
Jump to: navigation, search
(Created page with "file contents: <source lang="yaml"> webserver: hosts: foo: ipaddr: 192.168.1.1 desc: "foo" bar: ipaddr: 10.0.0.1 desc: "bar" </source> $ '...")

Revision as of 23:02, 6 December 2024

file contents:

webserver:
  hosts:
    foo:
      ipaddr: 192.168.1.1
      desc: "foo"
    bar:
      ipaddr: 10.0.0.1
      desc: "bar"


$ yq '.fg.hosts[] | select(.ipaddr == "192.168.1.1")' devices_test.yaml
{
 "ipaddr": "10.128.1.98"
}