• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

gcp

Gcloud Table vs CSV Format

September 18, 2023

Differences using gcloud table vs CSV format.

Table format

gcloud compute snapshots list \
--filter="sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$" \
--format="table(sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())" \
--sort-by "~creationTimestamp" \
--project="$PROJECT"

gcloud compute snapshots list \ --filter="sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$" \ --format="table(sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())" \ --sort-by "~creationTimestamp" \ --project="$PROJECT"

CSV format

gcloud compute snapshots list \
--filter="sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$" \
--format="csv[separator=','](sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())" \
--sort-by "~creationTimestamp" \
--project="$PROJECT"

gcloud compute snapshots list \ --filter="sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$" \ --format="csv[separator=','](sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())" \ --sort-by "~creationTimestamp" \ --project="$PROJECT"

Output to file

gcloud compute snapshots list \
--filter="sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$" \
--format="csv[separator=','](sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())" \
--sort-by "~creationTimestamp" \
--project="$PROJECT" > output.csv

gcloud compute snapshots list \ --filter="sourceSnapshotSchedulePolicy ~ $POLICY AND sourceDisk~$disk$" \ --format="csv[separator=','](sourceDisk.basename(),name,creationTimestamp,sourceSnapshotSchedulePolicy.basename())" \ --sort-by "~creationTimestamp" \ --project="$PROJECT" > output.csv

Filed Under: Cloud Tagged With: csv, format, gcloud, gcp, output, table

GCP Cloud Shell Format

September 18, 2023

If you are getting funky formatting in GCP Cloud Shell, run this to set the format.

gcloud config set accessibility/screen_reader False

gcloud config set accessibility/screen_reader False

Filed Under: Cloud Tagged With: cloud, format, gcp, set, shell

GCP VM Licenses

September 14, 2023

Here’s the command to display VM OS licenses.

#!/bin/bash
ts=$(date +%Y%m%d-%H%M%S)
log="gcp-licenses-logs-$ts"
>$log
while read -r project; do
    echo "Project: $project" | tee -a $log
    gcloud compute instances list --project $project --format="table[no-heading](name,zone.basename())" > instances.list
    while read -r instance zone; do
        gcloud compute instances describe $instance \
        --project $project \
        --zone $zone \
        --format="table[no-heading](name,zone.basename(),disks[0].licenses[0].basename())" | tee -a $log
    done < instances.list 
done < projectIds.txt

#!/bin/bash ts=$(date +%Y%m%d-%H%M%S) log="gcp-licenses-logs-$ts" >$log while read -r project; do echo "Project: $project" | tee -a $log gcloud compute instances list --project $project --format="table[no-heading](name,zone.basename())" > instances.list while read -r instance zone; do gcloud compute instances describe $instance \ --project $project \ --zone $zone \ --format="table[no-heading](name,zone.basename(),disks[0].licenses[0].basename())" | tee -a $log done < instances.list done < projectIds.txt

Filed Under: Cloud Tagged With: gcp, licenses, list, vm

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Interim pages omitted …
  • Go to page 47
  • Go to Next Page »
  • Home
  • About
  • Search

Copyright © 2023