![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can debug our UNIX shell script? | psiva_arul | UNIX for Advanced & Expert Users | 3 | 09-07-2008 07:31 AM |
| debug aix 4.3 | itik | AIX | 2 | 10-29-2007 08:56 AM |
| Debug an Awk Script | mboro | Shell Programming and Scripting | 1 | 10-01-2007 03:05 AM |
| how to debug | ramneek | High Level Programming | 1 | 09-19-2005 03:35 AM |
| disk space script debug - posted before | bryan | Shell Programming and Scripting | 3 | 04-28-2005 04:50 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to debug the awk script
Hi,
How can I debug an awk script? I know that set -x can be used to debug a script. But this will not suite for awk scripts. Can anyone help me? Thanks in advance, Chella |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
awk does not come with a built in debug option.
I have come across but never used awkdb: AWK Debugger Usually I just print out various messages or values of fields to see what is going on. If you are using gawk, you could recompile the source with the debugging option turned on to print out the parse stack information as gawk executes - but this will probably give you far more information than you can use. |
|
#3
|
||||
|
||||
|
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
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' See info awk for the situations about which --lint will complain ... cheers, drl |
||||
| Google The UNIX and Linux Forums |