How to get the one character’s next character in ASCII table in Bash? For example, if I have ‘a’ in variable
i, how to get ‘b’?
First, we need to get the integer value for the character.
char='b' charint=$(printf "%d" "'$char'")
Then, we increase the integer by one
Last, we can get the new character by converting the integer to the character
newchar=$(printf "\x$(printf %x $charint)")
The result is as follows.
$ echo $newchar c