|cvtbase||The bc command can be used to , 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
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:
where input_base and output_base are any of:
Decimal; i.e., digits
Hexadecimal (using lowercase); i.e.,
Hexadecimal (using uppercase); i.e.,
Octal; i.e., digits
Binary; i.e., digits
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.