Bash Associative Arrays
Apr 30, 2010, 12:32 (0 Talkback[s])
(Other stories by Mitch Frazier)
WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
"The bash man page has long had the following bug listed: "It's
too big and too slow" (at the very bottom of the man page). If you
agree with that, then you probably won't want to read about the
"new" associative arrays that were added in version 4.0 of bash. On
the other hand, if you've ever used any modern Office Suite and
seen code-bloat at its finest and just think the bash folks are
exaggerating a bit, then read on.
"There's nothing too surprising about associative arrays in
bash, they are as you probably expect:
declare -A aa
"The -A option declares aa to be an associative array.
Assignments are then made by putting the "key" inside the square
brackets rather than an array index. You can also assign multiple
items at once:"