所有文章

JQ命令

当key中包含点时或当key以数字开头时 docker inspect $container_id | jq -r ‘.[-1].NetworkSettings.Networks|.[“lenovo.com”].IPAddress

根据元素的值选择元素 echo ‘{ “data”: [ { “joinTime”: 1507521910625, “memo”: “”, “projectId”: 48, “projectName”: “jiajun2” }, { “joinTime”: 1507794370272, “memo”: “”, “projectId”: 49, “projectName”: “jiajun22” } ], “msg”: “”, “result”: 0 }’ | jq ‘.data[]|select(.projectName|startswith(“jiajun22”))|.projectId’ 或 kubeapi /api/v1/namespaces/p48-u25-jiajun2/pods/|jq -r –arg ip 172.210.130.86 ‘.items[]|select(.status.podIP==$ip)|.status’


编写日期:2020-05-08