What is the simplest way to remove a trailing slash from each parameter in the \'$@\' array, so that rsync copies the directories by name?
rsync
rsync -a
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