Adicione um caractere:
#!/bin/bash
AR=('foo' 'bar' 'baz' 'bat')
for i in ${!AR[*]}; do ←
echo "$i"
done
(Adicione um ponto de exclamação ( ! ) à expansão da matriz:
${!AR[*]} .) A partir da página man:
Parameter Expansion
︙
${!name[@]}
${!name[*]}List of array keys. If name is an array variable, expands to the list of array indices (keys) assigned in name. If name is not an array, expands to 0 if name is set and null otherwise. When
@is used and the expansion appears within double quotes, each key expands to a separate word.