help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Best way to remove trailing '/' from a path?


From: Stephane Chazelas
Subject: Re: [Help-bash] Best way to remove trailing '/' from a path?
Date: Mon, 20 Apr 2015 21:20:51 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

2015-04-10 22:11:37 -0500, Peng Yu:
> Hi, ${VAR%%+(/)} has been suggested here. But it is not robust if $VAR
> is just a bunch of slashes. Does anybody have a robust yet succinct
> implementation? Thanks.
> 
> http://stackoverflow.com/questions/9018723/what-is-the-simplest-way-to-remove-trailing-slashes-from-each-parameter
[...]

Try:

dirname -- "$VAR/."

-- 
Stephane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]