Ascii to caracter

Hi,

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

test=a
valeur=`printf %u "'$test"`
char=`expr $valeur + 1`
printf %c $char

It outputs "9" and I want to get "b"

>echo "g" | tr '[a-y]' '[b-z]'
>h

or

>trchar="j"
>echo $trchar | tr '[a-y]' '[b-z]'
>k

This would work for 25 letters of the alphabet

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

I have no idea why I'm getting the weird output

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.

Thanks everyone for your suggestions.

I tried joeyg's solution and it works. I'm probably going to use it since it's pretty simple and I'm not the one who will be using this.

I'm taking good note of your code though Perderabo, for personal comprehension :slight_smile: