請幫我弄清楚那個...
我想獲取名稱所在的 ID - terraform-02
jq '.[] | map(select(.name == "terraform-02"))'- 沒用,開始過濾程序
那是我的陣列:
{"ssh_keys": [ { "id": ..., "public_key": "...", "name": "terraform-02", "fingerprint": "." }, { "id": ..., "public_key": "...", "name": "terraform-02", "fingerprint": "..." }, ],"meta": {"total": 2}}
uj5u.com熱心網友回復:
鑒于此輸入:
{
"ssh_keys": [
{
"id": "id1",
"public_key": "pk1",
"name": "terraform-02",
"fingerprint": "..."
},
{
"id": "id2",
"public_key": "pk2",
"name": "terraform-02",
"fingerprint": "..."
}
],
"meta": {
"total": 2
}
}
你可以選擇.id這樣的:
jq '.[][] | select(.name? == "terraform-02").id'
輸出是:
"id1"
"id2"
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/476212.html
