Arrays.ksh

#!/bin/ksh

# Arrays.ksh

# Introducing arrays: a grouping of similar variables.
# A good use for an array would be an array to hold
# a list of groceries or the months of a year.

# - Jim

# To create an array:
# ArrayName[ElementNumber]="Value"

# Defining a counter:
index=7

# Example:
Child[0]="Tom"
Child[1]="Kate"
Child[7]="Colleen"

# Example of not using index 0.
Month[1]="January"; Month[2]="February"
Month[3]="March"; Month[4]="April"
Month[5]="May"; Month[6]="June"
Month[7]="July"; Month[8]="August"
Month[9]="September"; Month[10]="October"
Month[11]="November"; Month[12]="December"

# Printing a variable:
print "index is $index"

# Can not access an array element by $Month[7].

# To access the value in an array element.
print "The fifth month is: ${Month[5]}"

# To print all values in an array:

print "The whole array is: ${Month[*]}"