bug-bash
[Top][All Lists]
Advanced

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

Re: create array in loop with variable in array's name


From: pikta
Subject: Re: create array in loop with variable in array's name
Date: Sun, 30 May 2010 09:49:19 -0700 (PDT)



monoped wrote:
> 
> Am 29.05.2010 01:04, schrieb pikta:
>>
>> Hi all,
>> I'm just a beginer and I got stucked .... I'm trying to create multiple
>> array with variable in array's name. I would expect to have 3 arrays and
>> each of them would contain 3 elements like array1=(a b c)  array2=(a b c
>> )
>> array3=(a b c) ; what means that first element of array1[0]="a" and for
>> example third element of array3[2]="c". This is the way how I do it :
>>
>> for (( n=1; n<4; n++ ))
>> do
>> array$n=(a b c)
>> done
>>
>> ...but there is syntax error....
> 
> That's because array$n isn't a valid name. Use eval:
> 
>       eval "array$n=(a b c)"
> 
> Bernd
> 
> -- 
> Bernd Eggink
> http://sudrala.de
> 
> 
> 

Hi, thanks a lot for hint, it works as expected !!!! (I tried to give you 5
stars but somehow there  are only 3 and I can not chacge it ...; but thanks
a lot again!)

-- 
View this message in context: 
http://old.nabble.com/create-array-in-loop-with-variable-in-array%27s-name-tp28712785p28723207.html
Sent from the Gnu - Bash mailing list archive at Nabble.com.




reply via email to

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