#!/bin/bash
#converts kilobytes to Mega/Giga/Tera/Peta
usage()
{
cat << EOF
usage: $0 {number of Kilobytes}
eg
# $0 100
cumulative 100 kB
# $0 1000
cumulative 1000 kB
# $0 1024
cumulative 1024 kB
1 MB
# $0 100000
cumulative 100000 kB
97 MB
EOF
}
if [ $# != 1 ]
then
usage
exit 1
fi
cumulative=$1
echo cumulative $cumulative kB
let cumulativeMB=$cumulative/1024
if [ $cumulativeMB -ge "1" ]
then
echo $cumulativeMB MB
fi
let cumulativeGB=$cumulativeMB/1024
if [ $cumulativeGB -ge "1" ]
then
echo $cumulativeGB GB
let remainderGB=$cumulativeMB-1024
echo $remainderGB MB
fi
let cumulativeTB=$cumulativeGB/1024
if [ $cumulativeTB -ge "1" ]
then
echo $cumulativeTB TB
fi