Learning about Variable Arrays
A really cool feature of environment variables is that they can be used as arrays. An array is a variable that can hold multiple values. Values can be referenced either individually or as a whole for the entire array.
To set multiple values for an environment variable, just list them in parentheses, with values separated by spaces:
$ mytest=(one two three four five)
$
Not much excitement there. If you try to display the array as a normal environment variable, you'll be disappointed:
$ echo $mytest
one
$
Only the first value in the array appears. To reference an individual array element, you must use a numerical index value, which represents its place in the array. The numeric value is enclosed in square brackets:
$ echo ${mytest[2]}
three
$
To display an entire array variable, you use the asterisk wildcard character as the index value:
$ echo ${mytest[*]...