Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Substitution to remove tailing slash?

$
0
0
Heyas

I am trying to remove a tailing space, with substitution.
Already tried some multiple escapes with no luck, is that even possible?
Code:

echo $CHROOT
[ -z "$CHROOT" ] || \
        CHROOT="${CHROOT/\/$}"
echo $CHROOT
return

And all i get is:
Code:

:) paths $ CHROOT=/usr/local/
+ paths $ . *
/usr/local/
/usr/local/

Code:

$SHELL -version
GNU bash, version 4.3.33(1)-release (x86_64-redhat-linux-gnu)

The 2nd printed output, would be expected to be:
Code:

/usr/local
Thank you

EDIT:
I can check if the last string is a slash or not, but i thought a subs would work just fine?

Viewing all articles
Browse latest Browse all 16232

Trending Articles