Logo Computer scientist,
engineer, and educator
• Software • Utility corner

uconv — a general unit converter for the command line

Version 0.0.1, March 2013

What is this?

uconv is a general-purpose unit converter for use on the command line. It is primarily intended for domestic and general scientific applications, supporting conversions for length, area, volume, mass, force, energy, radiation dose, fuel economy, temperature, pressure, velocity, acceleration, and many others. For non-metric units, uconv favours UK variants over US ones, but the US versions are also available.

Why another unit converter?

There are many (perhaps too many) unit converter programs available; most have graphical interfaces. uconv is intended to be sufficiently flexible in its unit specification that it is faster to use than a graphical program.

An example of command line usage might be:

$ uconv 60 cuft m3
60 cubic feet = 1.69901 cubic metres
uconv recognizes a hundred or so basic units, but the pontential conversions are very much more extensive than this, as units can be combined. The program recognizes combined units in a variety of formats: m/sec, m/sec^2, m/sec2, m/sec/sec, etc.

In fact, uconv will convert between any pair of units that are dimensionally consistent. For example, you can convert joules per second per kilogram to calories per minute per pound, if you wish. The program won't attempt to convert, for example, minutes to metres — these are not dimensionally consistent units. However, any pair of measurements that can be reduced to the same basic set of core units (metre, gramme, second, newton, ampere) should be convertible. uconv will even convert units that are complementary, that is, having dimensions that are the inverse of one another. So it can convert, for example, minutes per mile into miles per hour.

uconv attempts to be very flexible in the way units are interpreted, so the user doesn't have to spent too much time studying a manual to find the proper format. So square meters, for example, can be entered as 'sq m', 'square meter', 'sq metres', 'm2', 'sqm', among many others. The usual SI prefixes — kilo, micro, etc — are recognized, both in full and as abbreviations.

uconv is written in ANSI-standard C, and will compile on more-or-less any platform. Binaries are available on this site for Windows (Cygwin and native console), Android using KBOX, and Fedora 14 Linux or similar.

Although there are many unit conversion applications around, I wrote uconv because I needed something that would work on the command line, on all the platforms I use, including Android. This means, essentially, a plain C program. The GNU 'units' utility almost fits the bill — units is hugely flexible but, for me, way too clunky in its use of the command line. In addition, its bloated database of obscure units makes it hard to find things when you're not sure of the name or abbreviation.

Please note: uconv is not related in any way to the Unicode converter with the same name.

Building and installation

To build from source, in general, unpack the source bundle and run make, followed by make install. To install a binary, just download the appropriate file from the list below, and copy it to any directory on the $PATH — /usr/bin is appropriate for Cygwin or Linux, c:\windows is suitable on Windows. Rename the file to 'uconv' or 'unconv.exe' if required. Building from source — if practicable — may be better even when there is a binary available, as this will also install the man page. In addition, the source might also be more up-to-date than the binaries.

Further information

See the uconv man page.


Copyright © 1994-2015 Kevin Boone. Updated May 18 2017