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: Chris F.A. Johnson
Subject: Re: [Help-bash] Best way to remove trailing '/' from a path?
Date: Mon, 20 Apr 2015 17:00:38 -0400 (EDT)
User-agent: Alpine 2.10 (DEB 1266 2009-07-14)

On Mon, 20 Apr 2015, Stephane Chazelas wrote:

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/."

$ var=q/////////
$ dirname -- "$VAR/."
/

--
Chris F.A. Johnson, <http://cfajohnson.com>



reply via email to

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