输入json:
[
{
"id": "89",
"hostname": "abcd"
},
{
"id": "89",
"hostname": "babcd"
}
]
如何修改以下过滤器以仅输出以“abcd”开头的主机名?
$ jq -r '.[]|select(.hostname | contains("abcd"))' jjjj
{
"id": "89",
"hostname": "abcd"
}
{
"id": "89",
"hostname": "babcd"
}
$ jq -r '.[]|select(.hostname | contains("^abcd"))' jjjj
$
解决方案: