format memory better

This commit is contained in:
Ville Rantanen
2015-07-13 14:40:57 +03:00
parent 012afcbd5e
commit 1ef4cff3b1

View File

@@ -2,10 +2,10 @@
function filesize { function filesize {
awk 'BEGIN{ x = '$1' awk 'BEGIN{ x = '$1'
split("B KB MB GB TB PB",type) split("K M G T P",type)
for(i=5;y < 1;i--) for(i=5;y < 0.1;i--)
y = x / (2^(10*i)) y = x / (2^(10*i))
str=int(y*10)/10 str=int(y*10)/10 type[i+2]
if (x==0) { str = "0" } if (x==0) { str = "0" }
print str print str
}' || return $? }' || return $?