Last active
December 20, 2022 05:52
-
-
Save andgineer/7da3ae95d5980b9c25fcd44c3a607841 to your computer and use it in GitHub Desktop.
Equivalent of "du" command for a Amazon S3 bucket's "folder". Shows sizes of "subfolders" in this "folder".
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 s3du { | |
readonly folder_to_scan=${1:?"The argument 's3://bucket/folder_to_scan/' must be specified."} | |
for subfolder in $(aws s3 ls "${folder_to_scan}" | grep PRE | awk '{print $2}'); do | |
echo "${folder_to_scan}${subfolder}:" | |
aws s3 ls "${folder_to_scan}${subfolder}" --recursive \ | |
--human-readable \ | |
--summarize \ | |
| tail -n2 | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment