Convert number to human readable format

Posted under others On By xpk

Sure you can do the math yourself but why not trust a tool. coreutils include a tool called numfmt which can convert a number to human readable format. Much like when you run df -h. On mac homebrew, the tool is called gnumfmt. Give it a try:

[code]
$ gnumfmt –to=iec-i –suffix=B 4812939778547
4.4TiB

$ echo 9.78Ti | gnumfmt –from=iec-i –to=iec
9.8T

$ echo 123.456Pi | gnumfmt –from=iec-i –to-unit=G
129452999
[/code]

 243 total views,  4 views today

Leave a comment

Your email address will not be published. Required fields are marked *