Shell Script Variables

Last Character

Get the last character of $a:

${a: -1}

Remove Slash from the End of a Variable

Remove a trailing slash from $a:

a=${a%/}