Now, we will look at the values stored in variables or fields using the print command. Its syntax is very simple, print var1, var2,…. Here, var1 and var2 are the variable or field names. A variable can also be an array element. To print the contents of an array, prefix the name of the array with the @ symbol, as follows:
- print $3: Prints the value stored in field $3
- print @arrayname: Prints the contents of array arrayname
- print n1, n2, n3: Prints the value stored in variable n1, n2, and n3
Let's print the value of variables num1, num2 and result in our running program, as follows:
gawk> print num1, num2, resultnum1 = 30num2 = 10result = untyped variable
Here, the result is still not assigned any value, ...