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> $ '...")
 
 
Line 15: Line 15:
  
 
  {
 
  {
   "ipaddr": "10.128.1.98"
+
   "ipaddr": "192.168.1.1"
 
  }
 
  }

Latest revision as of 17:03, 10 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": "192.168.1.1"
}