I have this array:
declare -A astr
I add elements to it:
astr[elemA]=123
astr[elemB]=199
But later on I need to know what are the indexes IDs (elemA and elemB) and list them.
echo "${astr[@]}" #this only get me the values...
arraybash
I have this array:
declare -A astr
I add elements to it:
astr[elemA]=123
astr[elemB]=199
But later on I need to know what are the indexes IDs (elemA and elemB) and list them.
echo "${astr[@]}" #this only get me the values...
Best Answer
You can get the list of "keys" for the associative array like so:
You can iterate over the "keys" like so:
Example
References