The last character of a string is very easy to remove in bash.
out="remove last char!"
echo "${out%?}"
returns
remove last char
To remove the last two characters:
out="remove last char!"
echo "${out%%??}"
returns
remove last cha
or use
out="remove last char!"
echo ${out:0:$((${#out})) - 2}
to also get
remove last cha
danke 🙂