Skip to content

Instantly share code, notes, and snippets.

@brianredbeard
Created December 29, 2014 20:00
Show Gist options
  • Save brianredbeard/717fcb9f8f834c5e9bd7 to your computer and use it in GitHub Desktop.
Save brianredbeard/717fcb9f8f834c5e9bd7 to your computer and use it in GitHub Desktop.
List information on Digital Ocean images
#!/bin/bash
source .do
output=$(curl -s -X GET "https://api.digitalocean.com/v2/droplets" -H "Authorization: Bearer $TOKEN")
if [ "$1" == "-a" ]; then
echo $output | jq -s '.[][][] | { name: .name?, id: .id?, ip_address: .networks.v4[].ip_address} | select(.name | contains("redbeard"))' | grep -v -f reserved
else
echo $output | jq -s '.[][][] | { name: .name?, id: .id?} | select(.name | contains("redbeard")) | .id' | grep -v -f reserved
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment