Reputation: 43079
I have an associative array:
declare -A hash
hash[one]=1
hash[two]=2
hash[third item]=3
How can I create an indexed array from the keys of this associative array?
Upvotes: 2
Views: 52
Reputation: 43079
To make an array with the keys from an associative array:
arr=("${!hash[@]}")
To make an array with the values:
arr=("${hash[@]}")
Note that you need the double quotes to prevent the shell from word splitting.
Upvotes: 3