Skip to content

Instantly share code, notes, and snippets.

@patrickpierson
Last active May 20, 2016 11:44
Show Gist options
  • Save patrickpierson/ecc7a71028ad8117407c3b031390217a to your computer and use it in GitHub Desktop.
Save patrickpierson/ecc7a71028ad8117407c3b031390217a to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -z "$1" ]; then
echo "-----------------------------"
aws s3 ls | awk '{print $3}'
echo "-----------------------------"
echo "Please enter a bucket name -- s3du bucket-name"
else
s3du=$(aws s3 ls s3://$1 --recursive | grep -v -E "(Bucket: |Prefix: |LastWriteTime|^$|--)" | awk 'BEGIN {total=0}{total+=$3}END{print total/1024/1024" MB"}')
printf "Bucket $1 is "
echo $s3du
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment