Convert decimal to base 36 alpha numeric in Bash | Linux

Here is a custom bash shell script function you can use to convert a decimal to a base 36 number in all capital alpha numeric.

Example:

your_digit=65;
decimal_to_base36 $your_digit;

Output:

1T

function decimal_to_base36(){
BASE36=($(echo {0..9} {A..Z}));
arg1=$@;
for i in $(bc <<< "obase=36; $arg1"); do
echo -n ${BASE36[$(( 10#$i ))]}
done && echo
}

Source: http://stackoverflow.com/questions/14471692/bash-base-62-to-decimal-conversion

comments powered by Disqus