shell substring last characters

C++
echo -n $str | tail -c 1
# gets the last character, increase number to get more characters
Source

Also in C++: