I am looking for simple array definition on awk by simple example. How to define array and use the elements of the array on awk language?
Awk does not have arrays, but maps.
Like all variables in awk, there is no need to define it. It will happen when you first use it.
To assign an element of a map:
a[key] = value
To use an element:
print a[key]
To iterate:
for (i in a) {
print i, a[i]
}
If you use integers as keys, the map will be equivalent to an array.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With