Tried to use bash arrays but for some reason this fails?

Solution 1:

It's not required that you declare your array upfront, but if you do, you need to use the lower case "a"; not the capital.

declare -a listofnames

Secondly, you need to use numerical indicies when referencing an array element

listofnames[one] <----- incorrect
listofnames[1]   <----- correct

So, for your two elements, it should look like this:

listofnames[1]="one test"
listofnames[2]="two test"

Or you assign all values at once, taking care of the first element having index 0

listofnames=("", "one test", "two test)