First page Back Continue Last page Graphics
Arrays
An array is a collection of items all of the same sort, stored in a single variable. Think, perhaps, of eggs in a 12-element array called an egg carton.
Arrays count from 0. You will forget this, usually at the worst possible time, so try hard to remember:
Arrays count from zero!
To declare an array: declare -a myArray1
To initialize:
declare -a myArray1=(1 2 3 4 5 6)
declare -a myArray2
myArray2=(1 2 3 4 5 6)
declare -a myArray3
read -a myArray3
[stdin] 1 2 3 4 5 6 [ENTER]