BEGIN {
print "1 ***";
split("abc",T,"");
T[5]="e";
T[26]="z";
T[25]="y";
for (i in T) printf("%i:%s ",i,T); print "";
for (i=1; i<=length(T); i++) printf(T); print ""
print "2 ***";
asort(T,U);
for (i in U) printf("%i:%s ",i,U); print "";
for (i=1; i<=length(U); i++) printf(U); print ""
}
and I don't understand the line following 2*** in the resulting display :
caused the array T to be filled with many null values. At the beginning, length(T) was 6. When i was incremented to 4, it created new array element T[4], etc.
In AWK, arrays are associative and array subscripts are always strings. Arrays can be sparse as in your example. If you use an array subscript (expression index) to refer to an array element that has no recorded value, i.e. T[10], then the value returned is "", the null string.
You can test whether a particular index exists, without the side effect of creating that element if it is not already present by using an
index in array
expression.
For more information, see Chapter 11 of Effective AWK Programming by Arnold Robbins.