Base Conversion Using cvtbase

cvtbase The bc command can be used to convert between different bases (), but an easier tool to use is cvtbase. cvtbase is designed specifically to convert from one format to another. For example, to convert a decimal IP address into its hexadecimal equivalent:


% cvtbase d h 140.186.65.25 8c.ba.41.19

The first argument, d, means that our input will be in decimal form. The second argument, h, means that we want the input converted into hexadecimal. In general, the syntax for calling cvtbase is:

cvtbase input_base output_base

where input_base and output_base are any of:

Any input characters that aren't in the specified set are sent through unchanged. In the example above, the dots () in the IP address are retained in the hexadecimal output.

- LM