I want to do something like this:
foo=( ) foo[0]=\"bar\" foo[35]=\"baz\" for((i=0;i<${#foo[@]};i++)) do echo \"$i: ${foo[$i]}\" done # Output: # 0: ba
You would find the array keys with "${!foo[@]}" (reference), so:
"${!foo[@]}"
for i in "${!foo[@]}"; do printf "%s\t%s\n" "$i" "${foo[$i]}" done
Which means that indices will be in $i while the elements themselves have to be accessed via ${foo[$i]}
$i
${foo[$i]}