O'Reilly logo

Learning AWK Programming by Shiwang Kalkhanda

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting watch and unwatch

We can add a watchpoint for a variable or a field so that whenever its value changes, the debugger stops. Each watch item is assigned a number that can be used to delete it from the watch list, using the unwatch command:

  • watch var: Sets watchpoint for variable var
  • unwatch [n]: Unsets the watchpoint specified with number n

Let's set the watchpoint for the variable result in our program calc.awk, which is being debugged, as follows:

gawk> watch resultWatchpoint 4: result

Here, we have set the watchpoint for the variable result, so during execution, whenever its value changes, the debugger will give a notification and stop there.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required