The commands for viewing and changing variables inside of gawk are:
$n) to the display list. The value of the variable or field is displayed each time the program stops. Each variable added to the list is identified by a unique number:
gawk> display x -| 10: x = 1
displays the assigned item number, the variable name and its current value.
If the display variable refers to a function parameter, it is silently
deleted from the list as soon as the execution reaches a context where
no such variable of the given name exists.
display displays the current values of
items on the list.
eval "awk statements
evalis similar, but it allows you to define “local variables” that exist in the context of the awk statements, instead of using variables or function parameters defined by the program.
gawk> print $3
This prints the third field in the input record (if the specified field does not exist, it prints ‘Null field’). A variable can be an array element, with the subscripts being constant values. To print the contents of an array, prefix the name of the array with the ‘@’ symbol:
gawk> print @a
This prints the indices and the corresponding values for all elements in
You can also set special awk variables, such as
$n) to the watch list. The debugger then stops whenever the value of the variable or field changes. Each watched item is assigned a number which can be used to delete it from the watch list using the
With a watchpoint, you may also supply a condition. This is an awk expression (enclosed in double quotes) that the debugger evaluates whenever the watchpoint is reached. If the condition is true, then the debugger stops execution and prompts for a command. Otherwise, gawk continues executing the program.