parameter-expansion

Bash array indices with @

Lists assigned indices or keys as separate words when double-quoted and used alone.

Formal Syntax & Structure

bash syntaxbash
"${!name[@]}"

Return Value

words

Lists assigned indices or keys as separate words when double-quoted and used alone.

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