Created
December 29, 2014 20:00
-
-
Save brianredbeard/717fcb9f8f834c5e9bd7 to your computer and use it in GitHub Desktop.
List information on Digital Ocean images
This file contains hidden or 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
| #!/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