I have a file with content like
12345
I need to convert this kind of strings like this:
"0"->"a"
"1"->"b"
...
"9"->"j"
So, 12345
should result in abcde
. I want to achieve this via the shell (bash). What is the best way to do this?
Thanks.
Using a calculator or a pencil and paper, add together every single digit from your name. If your name has 20 letters, you will be adding together 20 individual numbers. You will end up with a 2-digit sum after adding everything together. For example, BATMAN is numbers 2+1+2+4+1+5, which equals 15.
In any shell, you could use:
echo "$string" | tr 0123456789 abcdefghij
Or, in Bash and without a pipe:
tr 0123456789 abcdefghij <<< "$string"
(where the double quotes might not be necessary, but I'd use them to be sure).
echo 12345 | tr '[0-9]' '[a-j]'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With