In Bash I can create a map (hashtable) with this common construction
hput() {
eval "$1""$2"='$3'
}
hget() {
eval echo '${'"$1$2"'#hash}'
}
and then use it like this:
hput capitals France Paris
hput capitals Spain Madrid
echo "$(hget capitols France)"
But how do I best iterate over the entries in the map ?. For instance, in Java I would do:
for (Map.Entry<String, String> entry : capitals.entrySet()) {
System.out.println("Country " + entry.getKey() + " capital " + entry.getValue());
}
is there a common way of accomplishing something similar in Bash ?.