help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Specifying multiple index numbers in array


From: Jerry
Subject: Re: [Help-bash] Specifying multiple index numbers in array
Date: Fri, 3 May 2013 16:42:28 -0400

On Fri, 3 May 2013 15:55:42 -0400 (EDT)
Chris F.A. Johnson articulated:

> On Fri, 3 May 2013, Jerry wrote:
> 
> > I thought I saw a way to do this; however, I cannot find that
> > article.
> >
> > Assume I have and array with 7 items.
> >
> > declare -a FOO=(zero one two three four five six)
> >
> > now, if I wanted to extract index 2 and index 4, how could I do it?
> > I could use ${FOO[2]} and ${FOO[4]}; however, I wanted to do it in a
> > simpler fashion, something like ${FOO[2][4]} or something similar.
> > Is it possible?
> 
>    Use brace expansion:
> 
> echo "${FOO["{2,4}"]}"
> 
>    Note that the brace expression is not quoted.

Thank you. I cannot test it right now; however, I believe that is what
I saw described in a "How-To" article awhile ago.

-- 
Jerry ♔

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the Reply-To header.
__________________________________________________________________




reply via email to

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