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: 
```
y=b
echo "$y"  # this shows 'b'
y=$(echo "$y" | tr "0-9a-z" "1-9a-z_")
echo "$y"  # this shows 'c'

```

Note that this does not handle the case where $y = "\_" (not sure what you want then, and in any case it'll probably require separate handling), and if $y is more than one character long it'll "increment" all of them (i.e. "10" -> "21", "09g" -> "1ah", etc).
You can start with this:

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

```