Last active
December 17, 2015 10:29
-
-
Save drinkspiller/5595291 to your computer and use it in GitHub Desktop.
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
| #!/bin/bash | |
| human_filesize() { | |
| local fsize=$1 | |
| echo "fsize = $fsize" | |
| declare -a units=(' B', ' KB', ' MB', ' GB', ' TB') | |
| for (( i=0; $fsize > 1024; i++ )) | |
| do | |
| local fsize=$(echo "scale=2;$fsize/1024" | bc ) | |
| echo "now fsize = $fsize" | |
| done | |
| echo printf "%0.2f\n" "$fsize" | |
| } | |
| ############## | |
| # MAIN | |
| ############## | |
| bytes=$(/usr/bin/s3cmd --config="/home/ec2-user/.s3cfg" du s3://antidote-dam | awk '{print $1}') | |
| echo "bytes is: $bytes" | |
| echo $(human_filesize $bytes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment