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


Arrays in @command{awk}

An array is a table of values called elements. The elements of an array are distinguished by their indices. Indices may be either numbers or strings.

This major node describes how arrays work in @command{awk}, how to use array elements, how to scan through every element in an array, and how to remove array elements. It also describes how @command{awk} simulates multidimensional arrays, as well as some of the less obvious points about array usage. The major node finishes with a discussion of @command{gawk}'s facility for sorting an array based on its indices.

@command{awk} maintains a single set of names that may be used for naming variables, arrays, and functions (see section User-Defined Functions). Thus, you cannot have a variable and an array with the same name in the same @command{awk} program.


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