2 myarray
=('a a' 'vv' 'vvv' 'b b' 'c c')
4 declare -g -A myarray_index
5 for i
in "${!myarray[@]}"; do
6 eval myarray_index
["${myarray[$i]}"]=$i
11 # the "|| echo NOT FOUND" below is needed if you're using "set -e"
12 test "${myarray_index[$member]}" && echo FOUND ||
echo NOT FOUND
14 test "${myarray_index[$member]}" && echo FOUND ||
echo NOT FOUND
15 test "${myarray_index[a a]}" && echo FOUND ||
echo NOT FOUND
16 echo "${myarray_index[$member]}"
17 echo "${myarray_index[a a]}"
18 echo "${myarray_index[a]}"