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
0
1
2
3
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?
Asked by GZ-
(357 rep)
Aug 24, 2020, 03:55 PM
Last activity: Nov 18, 2024, 10:37 PM
Last activity: Nov 18, 2024, 10:37 PM