Go to the first, previous, next, last section, table of contents.


Arrays

Arrays are subscripted with an expression between square brackets (`[' and `]'). Array subscripts are always strings; numbers are converted to strings as necessary, following the standard conversion rules (see section Conversion of Strings and Numbers).

If you use multiple expressions separated by commas inside the square brackets, then the array subscript is a string consisting of the concatenation of the individual subscript values, converted to strings, separated by the subscript separator (the value of SUBSEP).

The special operator in may be used in a conditional context to see if an array has an index consisting of a particular value.

if (val in array)
        print array[val]

If the array has multiple subscripts, use `(i, j, ...) in array' to test for existence of an element.

The in construct may also be used in a for loop to iterate over all the elements of an array. See section Scanning All Elements of an Array.

You can remove an element from an array using the delete statement.

You can clear an entire array using `delete array'.

See section Arrays in awk.


Go to the first, previous, next, last section, table of contents.