Bash last char of a string

Bash shell is the common linux command language.
Post Reply
chris
Site Admin
Posts: 162
Joined: Mon Jul 21, 2008 9:52 am

Bash last char of a string

Post by chris » Sun Sep 02, 2018 7:11 pm

Hi,

does anyone know how to get the last characters of a string?
in bash.

Thanks

chris
Site Admin
Posts: 162
Joined: Mon Jul 21, 2008 9:52 am

Re: Bash last char of a string

Post by chris » Sun Sep 02, 2018 7:31 pm

Found a resolution:

This give sthe last character:

Code: Select all

echo "${FILENAME:$((${#str}-1)):1}"

Post Reply