associative array

A bash 4 array indexed by strings instead of numbers, declared with declare -A.

In more detail

It maps keys to values, like a small lookup table, as in owner[report]=ada. It must be declared before use and does not exist in bash 3.2, which is why a script that uses one should check BASH_VERSINFO first. The order of keys when you list them is not guaranteed.

Example

declare -A owner; owner[report]=ada; echo "${owner[report]}"

Related terms

Taught in

References