Hi.
This might help, at least in the early stages of developing an
awk script:
Code:
#!/usr/bin/env sh
# @(#) a1 Demonstrate one debugging feature in [g]awk.
set -o nounset
echo
## Use local command version for the commands in this demonstration.
echo "(Versions displayed with local utility \"version\")"
version >/dev/null 2>&1 && version bash awk
echo
awk --lint '
b == 1 { print " Found case for value of b is 1." }
' data1
exit 0
Producing:
Code:
% ./a1
(Versions displayed with local utility "version")
GNU bash 2.05b.0
GNU Awk 3.1.4
awk: cmd. line:2: (FILENAME=data1 FNR=1) warning: reference to uninitialized variable `b'
awk: cmd. line:2: (FILENAME=data1 FNR=2) warning: reference to uninitialized variable `b'
awk: cmd. line:2: (FILENAME=data1 FNR=3) warning: reference to uninitialized variable `b'
However, most
awk scripts are so short that it probably is not worth anyone's time to put in a lot of work doing a full debugger (well, it might be worth a grad student's time perhaps

)
See
info awk for the situations about which
--lint will complain ... cheers, drl