First page Back Continue Last page Graphics

Setting and Unsetting Arrays

declare -a myArray=(1 2 3 4 5 6)

myArray[3]=9 # 1 2 3 9 5 6

myArray[$i]=8 # if i = 0 then

# 8 2 3 9 5 6

someArray=( "a” "b” [3]="c” "d” )

# from index=[0]: "a” "b” - "c” "d”

# note that element 2 is undefined

unset myArray[1] # remove a single element

unset myArray # remove a whole array