I would like to iterate through all array (passed to function as parameter) elements. The error i am getting is: ./file: line x: ${$ARR[@]}: bad substitution Any suggestions how to solve this? The parameter i am passing to function is just name of the array, so basically, all i want to substitute is the $ARR in the for loop by the specific array name
Asked
Active
Viewed 83 times
0
-
Is your question: "Given the name of an array `$name = myarray` and an array `declare -a my_array`, how can I use `$name` to access `my_array`"? – Micha Wiedenmann Mar 27 '20 at 09:52
-
I might also be the case that you are looking for `${!name[@]}` (search for "indirect expansion" in [`man bash`](https://linux.die.net/man/1/bash)). – Micha Wiedenmann Mar 27 '20 at 10:00