In bash we can iterate over index of an array like this
~$ for i in "${!test[@]}"; do echo $i; done
where test is an array, say,
~$ test=(a "b c d" e f)
so that the output looks like
a
b c d
e
f
However, when I do the same in zsh I get an error:
➜ ~ for i in "${!test[@]}"; do echo $i; done
zsh: event not found: test[@]
What is going on?
What is the proper way of iterating over indices in zsh?
Go to Source
Author: Gao Zheng