If we have to access all the array elements, we can use a loop that executes once for each element of the array. In other programming languages, where indexes are sequentially numbered, a simple for loop construct is used to access the elements of array. Here, AWK has an associative array, so we use a special type of for loop to go through all the indexes of an array. Its syntax is as follows, followed by a listed explanation of the elements involved:
for (var in array)
body of loop
- var: This is any variable name, which is set to the index of the corresponding array element.
- in: This is a keyword.
- array: This is an array name.
- body of loop: This is a list of AWK statements that are to be executed. If you want ...