
Am I missing something?
All I seem to be able to get this to do is to print out HOW to do the conversion, not to actually do one. Is there any way to get this to actually DO a conversion? The man page is less than helpful in this area.
Am I missing something?
Hmm. Well, in the Unix spirit of things, maybe this is just meant to serve as a filter
for other programs. Given a pair of input units, you can get it to produce regular,
machine readable output:
4:05:12pm :chris% units feet meters * 0.3048 / 3.2808399 4:05:22pm :chris% units years seconds * 31556926 / 3.1688765e08 4:05:30pm :chris% units liters gallons * 0.26417205 / 3.7854118 4:05:49pm :chris%Maybe you could mess around with those result lines to do a conversion. For example, something like: "units [from] [to]  head 1" gives you your mathematical operator (whichever of multiplication or division, and the number to calculate against). You could then embed this within "printf" or (more flexibly) some Sed, Awk, or Perl code. In any event, I think you're right  this doesn't seem to be an allpurpose tool for making conversions so much as the raw engine for one, but like an engine with no wheels, that's not very useful without quite a bit of extra work. Too bad. On the brighter side, if you *do* want to extend it, it looks like you can add more conversions to the data file: /usr/share/misc/units.lib. I don't totally understand the format, but it looks like you should be able to go in (as root) and add, if nothing else, the values for fahrenheit & celcius conversions. Considering a lot of the other ones in there (e.g. kelvin), I'm surprised that those two were left out. Maybe it's the proverbial "exercise left to the reader".....
Am I missing something?
From experimenting a bit, it appears that there are at least a couple of ways to get the units program to do conversions. If you want to be prompted, run units and then enter the values along with the units to be converted, like this:
Am I missing something?
Whether invoked interactively or all via the command line, the syntax works out the same.
You give a value, and units A & B. The response line tells you how to get from A to B,
while the second line tells you how to get from B to A. So in your example, you have to
multiply by 176.786 if you want to go from feet to centimeters, and the second line tells
you that you have to divide by 0.0056566205 to get from centimeters to feet. Both lines
are giving you "the conversion"; the first line gives you A > B and the second line gives
you B > A. If you always invoke the command with the units you have first and the units
you want second (which makes more sense to me), then you'll always just be interested in
the first line.
No wait I'm horribly wrong. Upon closer inspection, the first line is always multiplication and the second line is always division. The numbers are mutually reciprocal: using liters & gallons, you get * 0.26... and / 3.78..., and if you take either of those numbers and divide one by it, you get the other: (3.78...) = (1 / 0.26...) && (0.26...) = (1 / 3.78...). SO, what you have here are two numbers that can get you from units of A to units of B. The only difference, as near as I can tell, is that you have a choice regarding whether you prefer multiplying or dividing to get your result. I have no idea why this would matter to anyone. Presumably some electrical engineer wrote this command back in the day, and it would be useful in that context as part of a larger script, as a database of conversion factors for arbitrary calculations. Considering that it doesn't actually do the calculations, but rather helps describe how to write the formula for the calculations, I can't see how this would be useful for most people. Some intrepid soul could probably extend this program in order to do that, but short of that, it looks like you still have to do the (easier, more mechanical part of the) work yourself...
Am I missing something?
You have: 2 feet 
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors 
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. 
Visit other IDG sites: 
Created this page in 0.05 seconds 