# access elements in an array
${my_array[0]}
${my_array[1]}
ARRAY=( "engineer " "CEO" "doctor" "teacher" )
for i in "${!ARRAY[@]}"
do
echo " index---------------content"
echo " $i ${ARRAY[$i]}"
done
#!/bin/bash
AR=([3]='foo' [5]='bar' [25]='baz' [7]='bat')
for i in "${!AR[@]}"; do
printf '${AR[%s]}=%s
' "$i" "${AR[i]}"
done
#In case you want to access an element just use an index
$array[0]
$array[1]
.....