Short and sweet, shell only solution:
convertB_human() {
NUMBER=$1
for DESIG in Bytes KB MB GB TB PB
do
[ $NUMBER -lt 1024 ] && break
let NUMBER=$NUMBER/1024
done
printf "%d %s\n" $NUMBER $DESIG
}
It doesn't show the decimal potion.
The let VAR=expression
is Korn-ish. Substitute with VAR=$(( expression ))
for Born-again-ish.