Artificial intelligent assistant

Code letters as numbers The script bellow is asking the user to enter something then it print the entry as an output: #!/bin/bash printf "\e[31mType/Enter something: $pdir\e[m "; read -e userInput if [[ -n "$userInput" ]] then pdir=$userInput fi printf "\e[96mYour code is: $pdir\e[m\n"; **My questions are:** 1. How can the previous code read only letters in "userInput"? 2. How can I convert my entry "userInput" as an output numbers for example if I enter "John" how can I get an output numbers.

Here are 2 ways that come to mind

convert each character to its ASCII value


$ echo John | perl -lne 'printf "%03d", ord for split ""'
074111104110


Or, if you don't strictly need _numbers_ , just a code, base64


$ echo John | base64
Sm9obgo=


* * *

To decode:


$ echo 074111104110 | perl -ne 'print chr for /(\d{3})/g'
John

$ echo Sm9obgo= | base64 --decode
John

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 8aca36e59c11046a1fb949fb9a401c66