Arrays are a collection of contiguous elements that can be
accessed by a subscript. Declaration of arrays in POSIX and Korn
Shell is very similar to that of the C Shell. An array's syntax
is:
The first line sets the element of the named array
at the designated subscript to the value.
Unlike C Shell, POSIX and Korn Shell start placement of values at
the 0 element.
In this example:
$ testa[0]=first $ testa[1]=second $ echo ${testa[1]} second $ echo ${testa[*]} first second |
the array testa
first two elements (0 and 1) are set to first
and second. The
following echos,
display the value of the 1 element and then the value of every array
element as designated by the *.
See “Parameter Substitution Conventions” for
other possible array subscripts and uses for arrays.