construct

Bash array compound assignment

Assigns a list of strings or explicit indexed elements; assignment replaces the indexed array contents.

Formal Syntax & Structure

bash syntaxbash
name=(value ...); name=([index]=value ...)

Return Value

exit status

Assigns a list of strings or explicit indexed elements; assignment replaces the indexed array contents.

Working Example

Example Snippetbash
items=([0]=alpha [5]=omega)printf 'count=%s\n' "${#items[@]}"for i in "${!items[@]}"; do  printf '%s=%s\n' "$i" "${items[i]}"done
Bash Reference