Skip to content

Instantly share code, notes, and snippets.

@tomlobato
Created January 24, 2016 19:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomlobato/d8b83c6ab2fdfc0d066e to your computer and use it in GitHub Desktop.
Save tomlobato/d8b83c6ab2fdfc0d066e to your computer and use it in GitHub Desktop.
Find Amazon S3 bucket usage
function s3size() {
for path in $*; do
size=$(aws s3 ls "s3://$path" --recursive | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {total=0}{total+=$3}END{printf "%.2fGb\n", (total/1024/1024/1024)}');
echo "[s3://$path]=[$size]";
done;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment