help-bash
[Top][All Lists]
Advanced

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

Re: Character clearance in either end front or back


From: Greg Wooledge
Subject: Re: Character clearance in either end front or back
Date: Thu, 8 Oct 2020 10:09:49 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Thu, Oct 08, 2020 at 02:56:18PM +0100, Chris Elvidge wrote:
> On 08/10/2020 12:19 pm, Greg Wooledge wrote:
> > On Thu, Oct 08, 2020 at 12:00:06PM +0200, Reuti wrote:
> > > > Am 08.10.2020 um 08:06 schrieb Budi <budikusasi@gmail.com>:
> > > > but merely
> > > > clearing \\\  as in l=foo\\\
> > > > 
> > > > k=${%%\}
> > > 
> > > To remove all you will need a wildcard:
> > > 
> > > k=${l%%\\*}
> > 
> > No, that won't do it either.  You need an extended glob.
> > 
> > shopt -s extglob
> > k=${l%%+(\\)}
> > 
> > Without extended globs, you could do it using a loop that removes one
> > backslash at a time, but that's obviously going to be slower.
> > 
> > 
> 
> l='foo\\\'
> echo ${l\\*} works for me. (bash 5.1.0)
> foo

Flawed test.  (Also, you didn't type the parameter expansion correctly.)

unicorn:~$ l='foo\\\bar\\\'
unicorn:~$ echo "${l%%\\*}"
foo

It chops too much.  This is not a valid solution to the stated problem.



reply via email to

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