Example
{
"name": "bar",
"thing": true,
"new_key": 0
}
{
"name": "baz",
"thing": false,
"new_key": 0
}
如果我跑.name
我得到的输出为
bar
baz
我想要的只是bar
您可以使用first/1 https://stedolan.github.io/jq/manual/#first(expr),last(expr),nth(n;expr)和这个结合-n/--空输入 flag.
jq -n 'first(inputs.name)'
Online demo https://jqplay.org/s/-MPl4kHmpw
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)