I need to create arrays from variables, via a loop.
The issue I have is with the array name creation. How do I use a variable to define an array?
I want to do something like
declare -a $H
where $H is my loop variable.
I then need to add items to each array I've created, something like this
$H=( ${$H[@]} "$I")
$I is the variable I'm using to loop in the array items.
I'm guessing that I'll need to use eval but nothing I've tried works. Escaping non-printable characters doesn't work either.
I can define an empty array using the $H variable, but I'm unable to add items to it or print out the full array item list.
I have no problems when defining a non-variable array name, but I need to create over 100 lookup tables, with number of items ranging from 1 to 10 -15 for each array, all from loop.
Thanks Guru, but not sure if this is what I'm after.
example of my code is:
e.g. Array name (H) could contain a persons name. The items (I) in the array could include things like address, phone number, D.O.B.
So I need to use a for loop to create the initial arrays (persons name), then use another for loop to populate the arrays with specific items. Then I need to be able to print out specific items or the entire array.
The issue looks to be with my variable expansion, but I could be wrong.