I wrote an awk script. It executed successfully untill I added quite a few lines of comments (for readability). The awk swcipt is 528 lines long with 17282 characters.
Any idea how I can get successful execution without removing the comments?
Generally, comments can be placed
conveniently except in a few cases.
Usually a comment is added at the right
side of an awk statement:
print $4 # special value for wombat v16
However, you should not put commnents in
when they will interfere with the parsing
that the awk interpreter does:
# special variable for finance cost="$112.16"
( cost will never be seen )
-OR-
/report/ { print $5" "$6" "$9" "$3" "\ # good info here
$2" "$1"\n"}
( line will not be continued as it should be )
These are O.K.:
# This report is interesting
# in that it shows the value
# of controlling costs
#if ( $5 == "totcost" { # oops, wrong test
if ( $5 ~ "totcost" { # test for correct string
print "The cost balances our needs"
} else { print "The cost is excessive"} # exceeds range
So, if you avoid conflict with the interpreter, all
should run just fine.
Since everything following the comment is ignored,
make sure that the comment does not actually void
an awk statement accidentally!
Also, if you didn't already know, a comment MUST be
preceded with the sharp sign ( # ) as shown above.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.