I'm trying to get from "a" to "b". So far, I've been able to get the ascii code for "a" and from there to get the code for "b". But, and this is were I'm stuck, I can't find how to show the symbol associated with the code I calculated. This is what I have right now
I changed you code little bit to try and I get the following output
printf "\<ascii number>" gives the ascii character for that value.
The "valeur" is taking the value of 97.
I assumed the value of "A" is 65.
When I run the following command in ksh I get the value of A as 101
This is really too much to do in a shell. But this works...
$ cat nextchar
#! /usr/bin/ksh
while : ; do
printf "enter a character - "
read char
printf "this char is %c \n" $char
val=$(printf "%c" $char | od -An -td1)
printf "decimal value is %d \n" $val
printf "octal value is %o \n" $val
((val=val+1))
octal=$(printf "0%o" $val)
nextchar=$(echo \\${octal})
printf "next char is %c \n" $nextchar
done
$ ./nextchar
enter a character - a
this char is a
decimal value is 97
octal value is 141
next char is b
enter a character - A
this char is A
decimal value is 65
octal value is 101
next char is B
enter a character - 1
this char is 1
decimal value is 49
octal value is 61
next char is 2
enter a character - !
this char is !
decimal value is 33
octal value is 41
next char is "
enter a character - ^C
$
To run this in bash, you probably need to change the echo or set the xpg_echo option.