Converting number from any base system to decimal in linux shell


You would like to quickly convert a number from a different base system (i.e. binary, octal, hexadecimal), to decimal.


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.

Taken from Linux Journal’s Work the Shell column (March 2016)