builtin-option

Bash declare -a

Declares an indexed array; indices are arithmetic expressions. Use trusted or validated indices.

Formal Syntax & Structure

bash syntaxbash
declare -a name[=(values ...)]

Parameters & Attributes

NameTypeDescription
nameidentifierArray variable.

Return Value

exit status

Declares an indexed array; indices are arithmetic expressions. Use trusted or validated indices.

Working Example

Example Snippetbash
declare -a items=(red 'dark blue')printf '%s\n' "${items[0]}" "${items[1]}"
Bash Reference