units of measurement
May 1st, 2007 mysurface Posted in Common, Misc, bc, units | Hits: 16387 |
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.
[䏿–‡ç¿»è¯‘ï¼½
Live Chat!









May 4th, 2007 at 8:45 pm
You can also perform online conversion via Google: 2.25 inch to cm
May 5th, 2007 at 1:18 am
You are right Carlos, and also for calculation. I did this on google
That’s amazing, thanks Carlos.