Bash arrays

In bash, there are two kinds of arrays:

  1. Indexed arrays; and
  2. Associative arrays.

Indexed arrays use numerical values as keys to access values stored in an array. However, keys for associative arrays are not limited to numeric values.

Indexed arrays

Declaring indexed arrays

declare -a arr

Associative arrays

Declaring associative arrays

declare -A arr


© Nicholas Shellabarger