I want to access the array index variable while looping thru an array in my bash shell script.
myscript.sh#!/bin/bash
A=('foo' 'bar' 'baz' 'bat')
for i in ${A[*]}; do
echo $i
done
Actual result
foo
bar
baz
bat
Desired result
0
1
2
3
How do I alter my script to achieve this?