Open tamalsaha opened 4 years ago
The values of an associative array are accessed using the following syntax ${ARRAY[@]}
.
To access the keys of an associative array in bash you need to use an exclamation point right before the name of the array: ${!ARRAY[@]}
.
To iterate over the key/value pairs you can do something like the following example
# For every key in the associative array..
for KEY in "${!ARRAY[@]}"; do
# Print the KEY value
echo "Key: $KEY"
# Print the VALUE attached to that KEY
echo "Value: ${ARRAY[$KEY]}"
done
Map with Array Values
https://www.artificialworlds.net/blog/2012/10/17/bash-associative-array-examples/
https://bytefreaks.net/gnulinux/bash/bash-how-to-iterate-over-associative-array-and-print-all-keyvalue-pairs