yq parser

From thelinuxwiki
Revision as of 17:03, 10 December 2024 by Nighthawk (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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": "192.168.1.1"
}