The Units Tool in Linux
Created On: 2016-10-23
GNU Units can be used for many things. It is such a useful tool that I always install it on any linux node.
Here is how I use it:
convert network speed. ISPs and network device use bit per second, downloaders usually use byte per second.
units 100Mbps MiB/s ; 11.92 MiB/s units 20Mbps MiB/s ; 2.38 MiB/s units 4Mbps KiB/s ; 488 KiB/s
calculate average download speed
units 800MiB/25min KiB/s ; 546.1 KiB/s
convert hard drive space. Operating systems show GiB/TiB, while vendors use GB/TB.
units 1TB GiB ; 931.3 GiB units 2TB GiB ; 1862.6 GiB
You can do calculation too:
units 2TB*24/3*0.8 TiB ; 11.6 TiB
doing time calculations
units '2 hour + 34 min + 1 day' ; 95640 s units '2 hour + 34 min + 1 day' hour ; 26.6 hour units 8mo weeks ; 34.8 weeks
convert between tps and maximum possible total request per day
units 132tps req/day ; 11404800 req/day units 132tps million*req/day ; 11.4 million*req/day
convert between (single node) tps and average response time
units 132tps ms/req ; 7.5 ms/req
convert foreign currency to local currency
units 39.99hkd usd ; 5.1 usd units 500hkd/mo usd/year ; 765 usd/year
You may have notice some units are not built-in. Units allow you to define your own units very easily. Here is my ~/.units file:
word ! words 1 word rmb ! cny rmb hkd 0.83 rmb usd 6.51 rmb euro 7.41 rmb eur euro jpy 0.058283 rmb inr 0.097 rmb rs inr sgd 4.75 rmb s$ sgd request ! req request r request tps req/s core !
You can define basic unit by using '!', you can define unit alias, you can
define conversion. See man units
for more information.