Skip to content

Instantly share code, notes, and snippets.

@delip
Created February 16, 2018 20:48
Show Gist options
  • Save delip/4d34d1dd5fa22eebf6a8e7b0f5d14c58 to your computer and use it in GitHub Desktop.
Save delip/4d34d1dd5fa22eebf6a8e7b0f5d14c58 to your computer and use it in GitHub Desktop.
`du -sh *` like script for an AWS bucket with mutliple keys
#!/bin/sh
BUCKET=$1
for obj in `aws s3 ls s3://$BUCKET/ | perl -pe 's/.*(PRE )(.*)/$2/'`
do
size=`aws s3 ls s3://$BUCKET/$obj --recursive --human --summarize | grep "Total Size" | cut -f2 -d':' | perl -pe 's/^\s+//g'`
printf "$obj\t$size\n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment