Summary
In this chapter, we learned about arrays. We learned that AWK provides one-dimensional associative arrays (arrays indexed by string values). We also learned how array elements are referenced using arr[index]
, and that it creates the element if it does not exist. Then we used the for
loop to scan through all the individual elements of an array, and tested the array membership using the in
operator with the if
expression. We used the split
function to create an array. We also learned how to delete an individual element or a whole array using the delete
command. Finally, we covered how AWK simulates multidimensional arrays by separating subscript values with commas. In this index, values are concatenated into a single string, separated by the value of SUBSEP
.
In the next chapter, we will learn about how to do pretty printing in AWK using formatted reports, and we will learn how to create one ourselves. We will also look at how to use redirection in AWK.