我想有一个输出,而不是定界空间,它应该像这样,使用jq
nodes.json
{
"nodes": {
"node1.local": {
":ip": "10.0.0.1",
"ports": [],
":memory": 1024,
":bootstrap": "bootstrap.sh"
},
"node2.local": {
":ip": "10.0.0.2",
"ports": [],
":memory": 1024,
":bootstrap": "bootstrap.sh"
},
"node3.local": {
":ip": "10.0.0.3",
"ports": [],
":memory": 1024,
":bootstrap": "bootstrap.sh"
}
}
}
这是我的命令使用
ips=`cat /vagrant/nodes.json | jq -r '.nodes | to_entries[] | [.value.":ip"] | @tsv'`
echo [\"$ips\"]
输出在哪里
["10.0.0.1 10.0.0.2 10.0.0.3"]
我希望它像这样
["10.0.0.1", "10.0.0.2", "10.0.0.3"]
$ jq -c '.nodes | to_entries | map(.value.":ip")' input
["10.0.0.1","10.0.0.2","10.0.0.3"]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句