[PLUG] awk syntax error, part ii

Fred James fredjame at fredjame.cnc.net
Fri May 25 18:35:12 UTC 2012


Rich Shepard wrote:
>    I've looked in the ORA book and on line without seeing what I've written
> incorrectly in this script:
>
> #! /usr/bin/awk -f
>
> BEGIN { FS = OFS = "|"}
>
> if ($3 ~ /Ag/ && $4 ~ /0.000/) { print $1, $2, $3, "-0.005" };
> else if ($3 ~ /Alk_tot/ && $4 ~ /0.000/) { print $1, $2, $3, "-1.000" };
> else if ($3 ~ /Cr/ && $4 ~ /0.000/) { print $1, $2, $3, "-0.030" };
> else if ($3 ~ /Fe/ && $4 ~ /0.000/) { print $1, $2, $3, "-1.200" };
> else if ($3 ~ /Mg/ && $4 ~ /0.000/) { print $1, $2, $3, "-1.000" };
> else if ($3 ~ /NO3-NO2/ && $4 ~ /0.000/) { print $1, $2. $3, "-0.020" };
> else if ($3 ~ /Na/ && $4 ~ /0.000/) { print $1, $2, $3, "-0.530" };
> else if ($3 ~ /Sb/ && $4 ~ /0.000/) { print $1, $2, $3, "-0.010" };
> else if ($3 ~ /Se/ && $4 ~ /0.000/) { print $1, $2, $3, "-0.003" };
> else if ($3 ~ /TDS/ && $4 ~ /0.000/) { print $1, $2, $3, "-15.000" };
> else { print $1, $2, $3, $4 }
>
>    awk tells me there's a syntax error at the start of each 'if' and 'else
> if' line. I've seen examples without the semi-colon and with it, but I've
> not found what I'm doing incorrectly. I also tried wrapping the body of the
> script in {} but that makes no difference, either.
>
>    A clue is needed.
>
> Rich
>   
Rich Shepard
All those semicolons ... ??? ... I don't think that is supported inside 
a script.
Regards
Fred James



More information about the PLUG mailing list