scripts
scripts copied to clipboard
si function shows wrong scale letter
The si function shows "M" instead of "G", "T" or "P"
I would be inclined to use a table-driven function like:
si() {
local v=$(($1)) l=${v#-} s=' kMGPTEZY'
! ((l = ${#l} / 3, l>=${#s} && (l = ${#s}-1) ))
printf '%d%s\n' "$((v * 1000 ** l))" "${s:l:l>0}"
}