One idea is to use awk to first create a conversion table between characters and ascii codes or numbers in the awin of awk, and then read the character table to be converted to output the corresponding conversion code. The following sample code converts a letter A-Z to a number 1-26, because shell is a string at the language level, so this conversion is called a better ing of one character to another.
Digit = 'echo $ {letter} | awk-v letter_cnt = 26' <br/> BEGIN {<br/> I = 0; <br/> for (I = 0; I <letter_cnt; I ++) <br/>{< br/> ch = sprintf ("% c", I + 65 ); <br/> trans_table [ch] = I; <br/>}< br/>{< br/> if (NF = 1) <br/>{< br/> printf ("% d", trans_table [$1]); <br/>}< br/>} ''<br/> if [$? -Ne 0-o "x $ {digit}" = "x"]; then <br/> echo "invalid letter, must be [A-Z] "<br/> else <br/> echo" transform right: $ {letter} -- >$ {digit} "<br/> fi <br/>