How to iterate over associative arrays in Bash

The keys are accessed using an exclamation point: ${!array[@]}, the values are accessed using ${array[@]}. You can iterate over the key/value pairs like this: for i in “${!array[@]}” do echo “key : $i” echo “value: ${array[$i]}” done Note the use of quotes around the variable in the for statement (plus the use of @ instead … Read more