Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cbea49f

Browse files
author
Ankam Ravi Kumar
authored
Create s3bucketsize.sh
1 parent 6762327 commit cbea49f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

AWS/s3bucketsize.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
#Purpose: To Know S3 Bucket Size Shell Script
3+
#Version:1.0
4+
#Created Date: 09-Jan-2019
5+
#Modified Date:
6+
#WebSite: https://www.server-computer.com
7+
#Author: Ankam Ravi Kumar
8+
# START #
9+
echo -e "Please Enter your Bucket Name: \c"
10+
read -r BUCKETNAME
11+
aws s3api list-objects --bucket $BUCKETNAME --output json --query "[sum(Contents[].Size)]" > $PWD/s3bucket
12+
sed -i 's/\[//' $PWD/s3bucket
13+
sed -i 's/]//' $PWD/s3bucket
14+
sed -i 's/ //' $PWD/s3bucket
15+
cat $PWD/s3bucket |head -2 |tail -1 |awk '{print int($1/1024)" KB"}'
16+
cat $PWD/s3bucket |head -2 |tail -1 |awk '{print int($1/1024/1024)" MB"}'
17+
cat $PWD/s3bucket |head -2 |tail -1 |awk '{print int($1/1024/1024/1024)" GB"}'
18+
cat $PWD/s3bucket |head -2 |tail -1 |awk '{print int($1/1024/1024/1024/1024)" TB"}

0 commit comments

Comments
 (0)