What is the simplest way to remove a trailing slash from each parameter?
The accepted answer will trim ONE trailing slash.
One way to trim multiple trailing slashes is like this:
VALUE=/looks/like/a/path///TRIMMED=$(echo $VALUE | sed 's:/*$::')echo $VALUE $TRIMMED
Which outputs:
/looks/like/a/path/// /looks/like/a/path
This works for me: ${VAR%%+(/)}
As described here http://wiki.bash-hackers.org/syntax/pattern
May need to set the shell option extglob. I can't see it enabled for me but it still works