[NBLUG/talk] Arrays in Bash

Ross Thomas boscorama at fastmail.us
Fri May 13 11:13:35 PDT 2011


On Fri, 13 May 2011 06:15 -0700, "Andrew" <argonaut at gmx.co.uk> wrote:
> 
> for i in ARRAY_ONE ARRAY_TWO
> do
>   echo ${i}         # Print the array name
>   echo "${i[2]}"    # Print the third element in the array
> done

Try using:
   eval echo "\${${i}[2]}"

Bash doesn't seem to like using a variable as an array name.

HTH

-- 
http://www.fastmail.fm - IMAP accessible web-mail




More information about the talk mailing list