I am using an array (clmlist01). I have 61 of these and have 4 or more references to each one in a block of code that I do not want to have to hardcode 61 times. With that being said, I am creating a varible and going through a for loop to create the actual name of each array. The arrays would end up being cmlist01, cmlist02, cmlist03, etc. I don't have any problem creating the variables, but I seem to be doing something wrong in the syntax because if I use ${#cmlist01[@]} it gives me 11, but if I try to resolve the variable substituion name (listnbr), it resoves to cmlist01, but the ${#listnbr[@]} always returns 1. Is it possible to do what I am trying, or do you have to always hardcode the actual array name (instead of resoving it on the fly)? Help with the syntax please!

I don't think it's possible though I'm not 100% sure.
Here is what I found in the advanced scripting link I refer to.


Variable length / Substring removal
String length (number of characters in $var). For an array, ${#array} is the length of the first element in the array.
* ${#*} and ${#@} give the number of positional parameters.
* For an array, ${#array
[*]} and ${#array[@]} give the number of elements in the array.

So if you ask me to guess (why it prints 1) I'll say either it's printing the length of the first element, or it's printing the number of elements in the array.