Преобразование в число и обратно

Простые типы / Символьный тип

char="A"

#printf with a quote before the character prints its code
intValue=$(printf '%d' "'$char")
#intValue is 65

intValue=$((intValue + 1))
#intValue is 66

#back: the code is turned into a \x escape and printf reads it
printf -v hexCode '%x' "$intValue"
printf -v charB "\\x$hexCode"
#charB is "B"

echo "intValue is $intValue"
echo "charB is $charB"