To measure a quantitative object, we usually use certain standard of units. To measure width or length of a piece of paper, we may use inches, centimeter or meter. Sometimes, the conversion between one system unit to another might not be straight forward. For examples convert inch to cm approximately, 1 inch is 2.54cm, 1 cm is 0.3937 inch.
With units, we can convert from one unit to another, e.g. 2.25 inch to cm.
units 2.25inch cm
The result will looks like this:
* 5.715 / 0.17497813
First line, is the result in cm. The second line is the inversion, It means (2.25 times 0.17497813) inch will be approximately 1 cm. Check it with bc,
echo "2.25*0.17497813" | bc -l
What if I just want the converted results to be printed? Make use of head, cut and pipelines.
units 2.25inch cm | head -n1 | cut -f2 -d' '
By the way, I discovered there exist online unit converter, WWW Unit Converter, which is pretty cool.