I am in need to use a cURL command to output 1 word which then will be then used within a variable.
The code that I am using is:
curl --request GET --url $URL --header "Authorization: Api-Token $APITOKEN" --data "name=$KUBENAME" | jq '.[]'
The output I currently get is: [ { "id": "KUBERNETES_CLUSTER-33EADA434F5DC0AE", "name": "dynakube-dev", "endpointUrl": null } ]
I would like to filter this output to show only the ID.
"KUBERNETES_CLUSTER-33EADA434F5DC0AE"
Is this possible?
CodePudding user response:
amended the end with:
| jq -c '[.values[] | .id]'
CodePudding user response:
Try following command,
echo '[ { "id": "KUBERNETES_CLUSTER-33EADA434F5DC0AE", "name": "dynakube-dev", "endpointUrl": null } ]' | jq '.[].id'
You can rewrite it with command as follows,
curl --request GET --url $URL --header "Authorization: Api-Token $APITOKEN" --data "name=$KUBENAME" | jq '.[].id'