If you declare an array like this
declare -a test
you can echo the value like this
i=2
echo ${test[i]}
or
i="1+1"
echo ${test[i]}
why the second form is accepted? i need a complex answer thanks
See man bash
:
The subscript is treated as an arithmetic expression that must evaluate to a number.
Complex enough?