Saturday, July 21, 2012

Convert units of measurement

How do you convert from 1 measurement unit to another unit? Say from kilometers to miles.

I can always look it up on that fridge magnet. This one local realtor likes to send me freebies like the fridge magnet with the common conversion factors.

If you don't have a handy fridge magnet, you can try the units command-line utility program.

To install it on a Debian system, enter:

# apt-get install units

# units 60km miles
 * 37.282272
 / 0.0268224

It tells you that 60 kilometers is equivalent to 37.282272 miles.

The second line (beginning with the '/') is somewhat confusing. It is saying, 60 km = 1 / 0.0268224 miles.

Running units in verbose mode makes it clearer.

# units -v 60km miles
 60km = 37.282272 miles
 60km = (1 / 0.0268224) miles

If you like to put spaces in your search parameters, remember to enclose it with quotes.

# units '60 km'  miles
 * 37.282272
 / 0.0268224

If you just want to know the conversion factors, do this:

# units km miles
 * 0.62137119
 / 1.609344

Very quickly, you know:
1 km = 0.62137119 mile, and
1 mile = 1.609344 km.

To many people, installing units and learning all that syntax may be a little too much work.

You can google the answer.

Simply bring up your web browser and go to the Google search page.

Enter this to search:
60 km in miles

The top item returned is the answer you are looking for.

Google Everything.

3 comments:

Jon Red said...

Yeah but if I'm at a command line anyway, this is more convenient. Hope you write more articles soon.

JoeBaloney said...

You ought to take a look at Frink. http://en.wikipedia.org/wiki/Frink
Its pretty incredible for this sort of thing.

Tiang Antrian said...

Yeah but if I'm at a command line anyway, this is more convenient. Hope you write more articles soon.