FreeKB - Convert a base 16 hexadecimal string to decimal in Linux
Convert a base 16 hexadecimal string to decimal in Linux

Home > Search


The echo command can be used to convert a base 16 hexadecimal string to decimal integer. For example, lets say you have the following base 16 hexadecimal string.

0x6599648e208ee4f6

 

0x is the prefix, and 6599648e208ee4f6 is the base 16 hexadecimal string (there are 16 characters, hence base 16). The following command will convert 0x6599648e208ee4f6 to decimal. In this example, 7320993230861821174 is the decimal.

~]# echo $((0x6599648e208ee4f6))
7320993230861821174

 

You can also convert a decimal string to hexadecimal. In this example, decimal string 7320993230861821174 is converted back into hexadecimal, without the leading 0x prefix.

~]# echo "obase=16; 7320993230861821174" | bc
6599648e208ee4f6

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments