Reputation: 10882
In Bash (v4+):
$ declare -A x=([foo]=bar [coconut]=banana)
$ echo ${x[@]}
gives:
banana bar
What can I type to get this:
foo coconut
Upvotes: 5
Views: 399
Reputation:
You can preceed x
in echo ${x[@]}
with a !
to get keys:
echo ${!x[@]}
More information on associative arrays: http://www.artificialworlds.net/blog/2012/10/17/bash-associative-array-examples/
Upvotes: 7