Problem
You would like to quickly convert a number from a different base system (i.e. binary, octal, hexadecimal), to decimal.
Solution
Use the echo $(()) shell command to convert it passing it the current base system and the number, as in $((2#101010)) or using the O for octal or 0x for hexadecimal notations.
Examples:
echo $(( 16#FF )) 255 echo $(( 0xFF )) 255 echo $(( 8#21 )) 17 echo $(( 021 )) 17
Taken from Linux Journal’s Work the Shell column (March 2016)