#!/bin/bash
P="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
C="012345678910111213141516171819202122232425"
OUT=`echo $1 | tr $P $C`
echo $OUT
I would like to translate the alphabets into decimal numbers starting from 0. I tried like the code I mentioned above. But the output is wrong starting from input 'K'. For e.g, when I enter DAD, the output is 303, but when the input is KILL, the output is 1800 which is giving me wrong one. K should be translated into 11 but it's taking only 1. My code is not working for the 2 digit decimal numbers.