bug-bash
[Top][All Lists]
Advanced

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

Re: feature suggestion: ability to expand a set of elements of an array


From: alex xmb sw ratchev
Subject: Re: feature suggestion: ability to expand a set of elements of an array or characters of a scalar, given their indices
Date: Wed, 26 Jun 2024 20:36:59 +0200

On Wed, Jun 26, 2024, 8:30 PM Chet Ramey <chet.ramey@case.edu> wrote:

> On 6/26/24 2:18 PM, Zachary Santer wrote:
>
> >> On Tue, Jun 11, 2024, 12:49 PM Zachary Santer <zsanter@gmail.com>
> wrote:
> >>>
> >>> $ array=( zero one two three four five six )
> >>> $ printf '%s\n' "${array[@]( 1 5 )}"
> >>> one
> >>> five
> >
> > This is different functionality.
>
> Equivalent to printf '%s\n' "${array[1}" "${array[5]}". The innovation Zach
> wants is to have a single word expansion to do this.
>

thank u sir ..

my sidethoughts about this :

declare a=( null one two three four five six ) b=( "${a["{1,5}"]}" ) ;
declare -p b ; eval printf %s\\\\n '${a['{1,5}']}'
declare -a b=([0]="one" [1]="five")
one
five

.. i dont really expect an answer back
greets tho ..  :))



-- 
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>                  ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/
>
>


reply via email to

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