Hi,
does anyone know how to get the last characters of a string?
in bash.
Thanks
Bash last char of a string
Re: Bash last char of a string
Found a resolution:
This gives the last character:
This gives the last character:
Code: Select all
echo "${FILENAME:$((${#str}-1)):1}"
Re: Bash last char of a string
you can also use:
Just remember that the last character can sometimes be a whitespace ( space, newline ...)
Code: Select all
echo ${STRING: -1}