Last active
June 1, 2016 13:03
-
-
Save gurdotan/c5f66e078767f34702efc59d5db18db8 to your computer and use it in GitHub Desktop.
S3: sum size of all objects in bucket/folder
This file contains 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
IFS=$'\n'; arr=(`for d in {0..182}; do date -d "2015-12-01 + $d days" +'%Y%m%d'; done`); for i in ${arr[@]} ; do aws s3 ls s3://bucket-name/production/dt=$i/ | tr -s " " | cut -f3 -d" " | paste -sd+ - | bc | numfmt --to=iec-i --suffix=B --padding=7 ; done |
This file contains 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
# S3 list bucket / folder | trim whitespace | cut size field | sum numbers | format to human readable format | |
aws s3 ls s3://bucket-name/production/dt=20160206/ | tr -s " " | cut -f3 -d" " | paste -sd+ - | bc | numfmt --to=iec-i --suffix=B --padding=7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment