Last active
August 11, 2019 15:54
-
-
Save slayer/5707b186a30f300c6c2f97acf9da9f14 to your computer and use it in GitHub Desktop.
AWS S3 du (disk usage) script
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
function aws-s3-du() { | |
local buckets=$@ | |
if [ -z "$buckets" ]; then | |
buckets=$(aws s3 ls | awk '{print $3}') | |
fi | |
for bucket in $buckets; do | |
echo -ne "${bucket}\t\t" | |
aws s3 ls s3://${bucket} --recursive | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024/1024" GB"}' | |
done | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment