Skip to content

Commit

Permalink
add bytes to human readable tool
Browse files Browse the repository at this point in the history
  • Loading branch information
ravomavain committed May 20, 2012
1 parent 457691e commit c535e6c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions bytestohr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# Convert input parameter (number of bytes)
# to Human Readable form
#

SLIST=(bytes Ko Mo Go To Po Eo Zo Yo)

POWER=0
VAL=$( echo "scale=2; $1 / 1" | bc)
VINT=$( echo $VAL / 1024 | bc )
while [[ $VINT != 0 && $POWER != 8 ]]
do
let POWER=POWER+1
VAL=$( echo "scale=2; $VAL / 1024" | bc)
VINT=$( echo $VAL / 1024 | bc )
done

echo $VAL ${SLIST[$POWER]}

0 comments on commit c535e6c

Please sign in to comment.