Skip to content

Instantly share code, notes, and snippets.

@exelban
Created March 11, 2020 09:38
Show Gist options
  • Save exelban/f153e9c55b24094fc504275e26f6fa88 to your computer and use it in GitHub Desktop.
Save exelban/f153e9c55b24094fc504275e26f6fa88 to your computer and use it in GitHub Desktop.
Script which deletes all snapshots from GCE (google compute engine)
#!/bin/bash
NUMBER=1000
list=""
while read -r line;
do
name=$(echo $line | awk '{print $1;}')
if [ "$name" != "NAME" ]; then
list+=" $name"
fi
done <<EOT
$(gcloud compute snapshots list --limit=$NUMBER)
EOT
yes | gcloud compute snapshots delete $list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment