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 15:46:24 -0400

On Fri, 3 May 2013 14:26:10 -0400
Greg Wooledge articulated:

> On Fri, May 03, 2013 at 01:54:42PM -0400, Jerry wrote:
> > 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?
> 
> You could get index 2 *through* index 4 using a range notation, but
> not 2 and 4 skipping 3.
> 
> printf '<%s> ' "address@hidden:2:3}"; echo
> 
> If you want 2 and 4 skipping 3, then using two separate expansions is
> the only way.

Thanks Greg. I though I had once seen a method of picking
non-consecutive elements, but I guess what you described is what I
actually saw.

-- 
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]