builtin-option

Bash declare -A

Declares a string-keyed array (Bash 4+). Empty keys are invalid; do not assume key enumeration order.

Formal Syntax & Structure

bash syntaxbash
declare -A name[=([key]=value ...)]

Return Value

exit status

Declares a string-keyed array (Bash 4+). Empty keys are invalid; do not assume key enumeration order.

Working Example

Example Snippetbash
declare -A settings=([theme]=dark [mode]=test)printf '%s\n' "${settings[theme]}" "${settings[mode]}"
Bash Reference