Array, as in any programming language, is a collection of elements. These elements need not be of the same type. One important difference here is shells support only one-dimensional arrays.
1. Creating an array:
Creating an array is pretty simple.
$ typeset -a arr
$ arr[0]=25
$ arr[1]=18
$ arr[2]="hello"
Using the typeset command, we let the shell know that we are intending to use the variable
arr to store a list of elements. The
-a indicates arr as an indexed array. Then the elements are assigned one by one using their index positions. Array indexing always starts from 0.