GNU Info

Info Node: (gawk.info)Arrays

(gawk.info)Arrays


Next: Functions Prev: Patterns and Actions Up: Top
Enter node , (file) or (file)node

Arrays in `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 `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 `awk' simulates
multidimensional arrays, as well as some of the less obvious points
about array usage.  The major node finishes with a discussion of
`gawk''s facility for sorting an array based on its indices.

   `awk' maintains a single set of names that may be used for naming
variables, arrays, and functions (*note User-Defined Functions:
User-defined.).  Thus, you cannot have a variable and an array with the
same name in the same `awk' program.

Array Intro
Introduction to Arrays
Reference to Elements
How to examine one element of an array.
Assigning Elements
How to change an element of an array.
Array Example
Basic Example of an Array
Scanning an Array
A variation of the `for' statement. It
loops through the indices of an array's existing elements.
Delete
The `delete' statement removes an element
from an array.
Numeric Array Subscripts
How to use numbers as subscripts in
`awk'.
Uninitialized Subscripts
Using Uninitialized variables as subscripts.
Multi-dimensional
Emulating multidimensional arrays in
`awk'.
Multi-scanning
Scanning multidimensional arrays.
Array Sorting
Sorting array values and indices.

automatically generated by info2www version 1.2.2.9