An associative array is one of awk's most powerful features. Associative arrays are like traditionals array except they uses strings as their indexes rather than numbers. When using an associative array, you can mimic traditional arrays by using numeric strings as indexes.
You assign a value to an element of an associative array just as you would assign
a value to any other awk variable. The format is shown below :-
array[string]=value
The array is the name of the array, string is the index of the element of the array you are assigning a value to, and value is the value you are assigning to the element of the array.
There is a special 'for' structure you can use with an awk array. The format is :
for (elem in array) action
The elem is a variable that takes on the values of each of the elements in the array as the 'For' structure loops through them, array is the name of the array, and action is the action that awk takes for each element in the array. You can use the elem variable in this action.
You can try associative arrays in the programming exercise related to tutorial six.