I have below json i want to take out all the macaddress list in one jason array how do i do ?
{
"facts_hash": {
"lib": "/usr/share/fdi/facts:/opt/extension/facts",
"interfaces": "eno1,eno2,eno3,eno4,eno5,eno6,ens3f0,ens3f1,lo",
"ipaddress_eno1": "192.168.101.135",
"macaddress_eno1": "08:f1:ea:6d:03:3c",
"netmask_eno1": "255.255.255.0",
"mtu_eno1": "1500",
"macaddress_eno2": "08:f1:ea:6d:03:3d",
"mtu_eno2": "1500",
"macaddress_eno3": "08:f1:ea:6d:03:3e",
"mtu_eno3": "1500",
"macaddress_eno4": "08:f1:ea:6d:03:3f",
"mtu_eno4": "1500",
"macaddress_eno5": "b8:83:03:81:4b:20",
"mtu_eno5": "1500",
"macaddress_eno6": "b8:83:03:81:4b:21",
"mtu_eno6": "1500",
"macaddress_ens3f0": "b8:83:03:84:d5:1c",
"mtu_ens3f0": "1500",
"macaddress_ens3f1": "b8:83:03:84:d5:1d",
},
"name": "daisy-joni-selitto-quinto",
"id": 269
}
jq does the trick as recommended by jack.. and here is the clear jq expression..
jq '[.facts_hash | to_entries[] | select(.key|startswith("macaddress_")).value]'
Thanks Jack once again for your help..