尝试基于addrtype
过滤json,如果addr
为addrtype
,则打印ipv4
;如果vendor
为{{1},则打印addrtype
}。
到目前为止,我有mac
会导致:
'"\(.addr) \(.addrtype) \(.vendor)"'
所需结果:
"192.168.1.235 ipv4 null"
"18:B4:30:8D:AE:BA mac Nest Labs"
"192.168.1.236 ipv4 null"
"18:B4:30:8D:B6:18 mac Nest Labs"
"192.168.1.238 ipv4 null"
"0C:EA:C9:AF:4F:72 mac null"
"192.168.1.254 ipv4 null"
"0C:EA:C9:AF:4F:70 mac null"
数据:
192.168.1.235 - Nest Labs
192.168.1.236 - Nest Labs
192.168.1.238 -
192.168.1.254 -
答案 0 :(得分:1)
这将产生所需的结果:
jq -sr '.[] | "\(.[0].addr) - \(.[1].vendor//"")"' file