Linux / UNIX: Convert Hexadecimal to Decimal Number

You can use the printf command in Bash to convert hexadecimal numbers to decimal. Here is an example:

$ printf "%d\n" 0x2a
42

In the above example, 0x2a is a hexadecimal number, and the printf command is used to convert it to decimal format. The %d format specifier is used to specify that the output should be in decimal format, and the \n is used to add a newline character to the end of the output.

You can replace 0x2a with any other hexadecimal number that you want to convert to decimal.

Leave a Comment