Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save theqwan-chengwei/c767d852b7d4f4bd26c1e625408dad5c to your computer and use it in GitHub Desktop.
Save theqwan-chengwei/c767d852b7d4f4bd26c1e625408dad5c to your computer and use it in GitHub Desktop.
get_dropbox_space_usage.sh
#!/bin/bash
DATA=$(curl -X POST https://api.dropboxapi.com/2/users/get_space_usage --header 'Authorization: Bearer your_token' --header 'Content-Type: application/json' --data 'null')
used=$(echo $DATA | sed 's/}//g' | awk '{ print $2}' | sed 's/,//g')
allocated=$(echo $DATA | sed 's/}//g' | awk '{ print $7}')
echo "total space(bytes):" $allocated
echo " used space(bytes):" $used
php -r "echo ($allocated - $used) / 1024 / 1024 / 1024 . 'GB';"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment