Remove a character from the end of a variable
I think better solution to canonize paths is realpath $path
or with -m
option if it doesn't exist.
This solution automaticaly removes unnecessary slashes and adds pwd
Use target=${1%/}
See this the parameter substitution of this bash scripting guide for more.
Use
target=${1%/}
A reference.