bash version 4 and associative arrays

The new builtin array variable BASH_ALIASES is a nice example for an associative array.
If you do an ”echo ${BASH_ALIASES[@]}” you see all the values, if you do a “set | fgrep BASH_ALIASES” you see, to what the indexes map.

Update:

In December, when I got aware of the new feature, I thought, there is no way to get the list of indexes.
But there is:  ${!name[@]} and ${!name[*]} return the list of array keys. This gets explained in the section Parameter Expansion. I am sorry, if my former statements caused confusion.


Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.