Bash supports two types of one-dimensional arrays. Multidimensional arrays aren’t supported.
- Indexed Arrays
- Associative Arrays
Indexed Arrays #
Indexed arrays use integer numbers as keys.
Associative arrays (aka dictionaries) #
Associative arrays use nonempty strings as keys.
Referencing #
Referencing array variables and their individual elements.
Uses arrname[subscript]
syntax. For indexed arrarys subscript
is any valid
arithmetic expression
and for
associative arrays subscript
is a nonempty string.
i[akraker@localhost]$ arr=('Peter' 'Anna' 'Greg' 'Jan')
i[akraker@localhost]$ echo ${arr[0]}
Peter