AWK – Array Membership Operator

  • Post author:
  • Post category:AWK
  • Post comments:2 Comments
AWK - Array Membership Operator

This topic is about AWK – Array Membership Operator.

It is represented by in. It is used while accessing array elements. The following example prints array elements using this operator.

Example

[jerry]$ awk 'BEGIN { 
   arr[0] = 1; arr[1] = 2; arr[2] = 3; for (i in arr) printf "arr[%d] = %d\n", i, arr[i]
}'

On executing this code, you get the following result −

Output

arr[0] = 1
arr[1] = 2
arr[2] = 3

In this topic we learned about AWK – Array Membership Operator. To know more, Click Here.

This Post Has 2 Comments

Leave a Reply