Google Cloud CLI (gcloud) cheatsheet
Google Cloud CLI (gcloud): Output and filtering
4 common Google Cloud CLI (gcloud) tasks.
Choose the output format
Print results as JSON. Other formats include yaml, table and value.
gcloud compute instances list --format json
Capture a single value
Print a bare field, suited to scripts.
PROJECT=$(gcloud config get-value project)
Filter resources
Filter results on the server side.
gcloud compute instances list --filter "status=RUNNING AND zone:us-central1"
Skip confirmation prompts
Accept defaults without asking, as scripts need.
gcloud compute instances delete my-vm --zone us-central1-a --quiet
Caution: --quiet confirms destructive actions for you.