1

How to convert numbers to the first letters of the alphabet? . I want to use this code for me. But I need alphabets for 10,11,12,13 etc. for example if the user will enter 10 , the program will print j for 11 -->"k" . How cam I do this. My code is same in the link above

Community
  • 1
  • 1
esrtr
  • 99
  • 2
  • 12

2 Answers2

3

You can use this BASH function:

cnvt() { printf "\x$(printf '%x' $((97 + $1 -1)))\n"; }

Test it:

cnvt 10
j
cnvt 11
k
cnvt 26
z
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • What I have in my answer is indeed the shell script. Just add my given inside any shell script and use it the way I suggested here. – anubhava Oct 27 '15 at 21:20
  • for example , when I write 35 , it gives me 'z' .Is it possible ? I know when I write 26 i gives 'z' . but ıt is possible for in ascii codes ? – esrtr Oct 27 '15 at 21:51
  • `cnvt 35` prints a printable character i.e. ASCII code 132 – anubhava Oct 27 '15 at 21:57
1

You can use ASCII table for this.
If user inputs 10 you can add 87 and get "a" = 97.
This way input 11 will get a value of "b" = 98.

MikeL
  • 5,385
  • 42
  • 41