vendredi 16 janvier 2015

Use a variable as part of name of an array name?


I essentially have a for loop where the variable "i" that I am iterating with will take on each letter of the alphabet, for example. I want to use each value of i to create an array called "$i"array (for instance aarray, barray, carray, darray, etc) or even just called "$i" (so the arrays could be called a, b, c, d, etc.) What kind of syntax could I use to make this happen?


for i in ${alphabet[@]}; do "$i"array[0]=0 done


and once I have my group of arrays, could I iterate through them by doing


for i in ${alphabet[@]}; do "$i"array[0]=1 done


Thank you!



Aucun commentaire:

Enregistrer un commentaire