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:

$ gnumfmt –to=iec-i –suffix=B 4812939778547

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

$ echo 123.456Pi | gnumfmt –from=iec-i –to-unit=G

 309 total views,  2 views today

Leave a comment

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