We have to pass the option --debug or -D, in addition to the -f option used to supply the AWK script on the command line. We cannot use GAWK debug for command line programs. It is essential to run awk commands from files with the -f option to launch the GAWK debugger as follows:
$ gawk -D -f calc.awk
Now, instead of immediately executing the program from calc.awk and returning the output on screen, this time GAWK loads the program source files, compiles them and gives us a prompt, as follows:
From this prompt, we can issue commands to the debugger. At this point, no code has been executed.