Last active
July 21, 2024 17:24
-
-
Save vadirajks/105734b2eeea5caa60012c6daa0a907e to your computer and use it in GitHub Desktop.
sort the fields from the gcloud compute instances list command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list_vm_gcp() { | |
gcloud compute instances list --project $1 '--format=json(NAME:sort=0,ZONE:sort=1,MACHINE_TYPE,PREEMPTIBLE,INTERNAL_IP,EXTERNAL_IP,STATUS,creationTimestamp:sort=2)' | jq -r '.[] |[.name, (.zone | split("/")[-1]), (.machineType | split("/")[-1]), .scheduling.preemptible, .networkInterfaces[0].networkIP, (.networkInterfaces[0].accessConfigs[0].natIP // "N/A"), .status, .creationTimestamp] | @tsv'| sort -t$'\t' -k8,8 -k2,2 -k1,1 | column -t | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment