bug-bash
[Top][All Lists]
Advanced

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

Re: Bash substrings: wish for support for negative length (read till n f


From: Jan Schampera
Subject: Re: Bash substrings: wish for support for negative length (read till n from end)
Date: Tue, 08 Jul 2008 06:31:44 +0200
User-agent: IceDove 1.5.0.14eol (X11/20080509)

Richard Neill wrote:

> $ echo ${stringZ:2: -1}               #Wish: start at 2, read till
> ERROR                         #1 before the end. i.e.
>                               # cde
> 
> $ echo ${stringZ: -3: -1}     #Wish: start 3 back, read till
> ERROR                         #1 before the end. i.e.

Use (-1), i.e.

$ echo ${stringZ:2:(-1)}

See also
http://bash-hackers.org/wiki/doku.php/syntax/pe#substring_expansion (at
bottom of the section).

J.




reply via email to

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