The Google Cloud Platform(GCP) provides a handy CLI tool to interact with its service – gcp cloud sdk or gcloud command. Here are some tips to format the output of this command in a tabular format.
Let us list the zones in GCP and by default this is what the output looks like –
$ gcloud compute zones list
NAME REGION STATUS NEXT_MAINTENANCE TURNDOWN_DATE
us-east1-b us-east1 UP
us-east1-c us-east1 UP
us-east1-d us-east1 UP
us-east4-c us-east4 UP
us-east4-b us-east4 UP
us-east4-a us-east4 UP
us-central1-c us-central1 UP
us-central1-a us-central1 UP
us-central1-f us-central1 UP
us-central1-b us-central1 UP
us-west1-b us-west1 UP
us-west1-c us-west1 UP
us-west1-a us-west1 UP
europe-west4-a europe-west4 UP
europe-west4-b europe-west4 UP
europe-west4-c europe-west4 UP
europe-west1-b europe-west1 UP
europe-west1-d europe-west1 UP
europe-west1-c europe-west1 UP
europe-west3-c europe-west3 UP
europe-west3-a europe-west3 UP
europe-west3-b europe-west3 UP
europe-west2-c europe-west2 UP
europe-west2-b europe-west2 UP
europe-west2-a europe-west2 UP
asia-east1-b asia-east1 UP
asia-east1-a asia-east1 UP
asia-east1-c asia-east1 UP
asia-southeast1-b asia-southeast1 UP
asia-southeast1-a asia-southeast1 UP
asia-southeast1-c asia-southeast1 UP
asia-northeast1-b asia-northeast1 UP
asia-northeast1-c asia-northeast1 UP
asia-northeast1-a asia-northeast1 UP
asia-south1-c asia-south1 UP
asia-south1-b asia-south1 UP
asia-south1-a asia-south1 UP
australia-southeast1-b australia-southeast1 UP
australia-southeast1-c australia-southeast1 UP
australia-southeast1-a australia-southeast1 UP
southamerica-east1-b southamerica-east1 UP
southamerica-east1-c southamerica-east1 UP
southamerica-east1-a southamerica-east1 UP
asia-east2-a asia-east2 UP
asia-east2-b asia-east2 UP
asia-east2-c asia-east2 UP
asia-northeast2-a asia-northeast2 UP
asia-northeast2-b asia-northeast2 UP
asia-northeast2-c asia-northeast2 UP
asia-northeast3-a asia-northeast3 UP
asia-northeast3-b asia-northeast3 UP
asia-northeast3-c asia-northeast3 UP
europe-north1-a europe-north1 UP
europe-north1-b europe-north1 UP
europe-north1-c europe-north1 UP
europe-west6-a europe-west6 UP
europe-west6-b europe-west6 UP
europe-west6-c europe-west6 UP
northamerica-northeast1-a northamerica-northeast1 UP
northamerica-northeast1-b northamerica-northeast1 UP
northamerica-northeast1-c northamerica-northeast1 UP
us-west2-a us-west2 UP
us-west2-b us-west2 UP
us-west2-c us-west2 UP
Now let us output this in tabular format and only print the GCP zones we are interested in –
$ gcloud compute zones list --format="table[box,title=GCP-REGIONS](name,region,status)" --filter='name~europe'
┌──────────────────────────────────────────┐
│ GCP-REGIONS │
├─────────────────┬───────────────┬────────┤
│ NAME │ REGION │ STATUS │
├─────────────────┼───────────────┼────────┤
│ europe-west4-a │ europe-west4 │ UP │
│ europe-west4-b │ europe-west4 │ UP │
│ europe-west4-c │ europe-west4 │ UP │
│ europe-west1-b │ europe-west1 │ UP │
│ europe-west1-d │ europe-west1 │ UP │
│ europe-west1-c │ europe-west1 │ UP │
│ europe-west3-c │ europe-west3 │ UP │
│ europe-west3-a │ europe-west3 │ UP │
│ europe-west3-b │ europe-west3 │ UP │
│ europe-west2-c │ europe-west2 │ UP │
│ europe-west2-b │ europe-west2 │ UP │
│ europe-west2-a │ europe-west2 │ UP │
│ europe-north1-a │ europe-north1 │ UP │
│ europe-north1-b │ europe-north1 │ UP │
│ europe-north1-c │ europe-north1 │ UP │
│ europe-west6-a │ europe-west6 │ UP │
│ europe-west6-b │ europe-west6 │ UP │
│ europe-west6-c │ europe-west6 │ UP │
└─────────────────┴───────────────┴────────┘
You can get more details on formatting your output with –
gcloud topic formats --help
References –
Linux System Admins Journey to Google Cloud Platform As a Linux system administrator, you have…
As a network professional, troubleshooting is a crucial part of your daily routine. To streamline…
The net-tools set of packages had been deprecated years back, although the commands are still…
Re-posting my answer to a Google cloud platform's Google Kubernetes Engine (GKE) related question in…
Recently I was trying to download numerous files from a certain website using a shell…