Skip to content

Instantly share code, notes, and snippets.

@drinkspiller
Last active December 17, 2015 10:29
Show Gist options
  • Save drinkspiller/5595291 to your computer and use it in GitHub Desktop.
Save drinkspiller/5595291 to your computer and use it in GitHub Desktop.
#!/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