Question: I have a set of valid characters [0-9a-z\_] and a variable that is assigned one of these characters. What I want to do is to be able to increment that variable to the next in the set.

If need be I can handle the "special" cases where it would increment from '9' to 'a' and 'z' to '\_', but I can't figure out how to increment letters.

```
#!/bin/bash
y=b
echo $y  # this shows 'b'
y=$((y+1))
echo $y  # this shows '1', but I want it to be 'c'

```

Answer: 
**for those who would like to print incremented letter by execution of a function**:

```
ALPHA=( {A..Z} ) 
alpha_increment () { echo ${ALPHA[${i:-0}]}; ((i++)) ;}

```

---

```
alpha_increment
A
alpha_increment
B
alpha_increment
C

```
You can start with this:

```
 echo 0x$(( $(printf "%x" "'b'") + 1)) | xxd -r

```