Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

brace expansion in array subscript



Hi,

I'm wondering if it's possible to somehow specify a set of indices to an 
array using brace expansion, to get a subset of the indices?  To get 
indices 2 and 5 of the array "arr", I'd like to use something like:

arr=( elt1 elt2 elt3 elt4 elt5 elt6 ) 
echo ${arr[{2,5}]}

Why doesn't that get expanded into "echo ${arr[2]} ${arr[5]}"?

It seems there would be lots of convenient uses of this feature.

Thanks in advance,
Rory



Messages sorted by: Reverse Date, Date, Thread, Author