Urgent help with awk programming....
Hi,
I encounter some error while trying to run an awk program as below :
awk '{a=substr($0, 52,4)
if (a ~ /MS/ || a ~/MG/ || a ~/SS/ || a ~ /SM/ ||
a ~ /AJ/ || a ~/HY/ || a ~/HL/ || a ~ /CC/ ||
a ~ /AP/ || a ~/NL/ || a ~/MP/ || a ~ /VT/ ||
a ~ /NC/ || a ~/NU/ || a ~/OR/ || a ~ /PO/ ||
a ~ /ND/ || a ~/SD/ || a ~/EU/ || a ~ /LT/ ||
a ~ /HU/ || a ~/NY/ || a ~/TS/ || a ~ /SO/ ||
a ~ /HJ/ || a ~/DO/ || a ~/PI/ || a ~ /PL/ ||
a ~ /AT/ || a ~/AV/ || a ~/MB/ || a ~ /MW/ ||
a ~ /MO/ || a ~/ML/ || a ~/MH/ || a ~ /MN/ )
print}' $src_file > $tmp_file
It will give me an error such as invalid syntax at line 3.4.5 etc...
In addition,I will get an error bailing out message near the last line...which is print}' $src_file > $tmp_file
Can someone please help and advise? This is quite urgent. Thanks.
It works fine here:
I can't tell if it does what it's supposed to, but it doesn't give me any errors (the output is empty).
bytecoder@fireball:~ $ cat > testASD;FKJSD;FLKJSD;FKSJDF;LJS;FKNSKDFSFAJSDLFJS;DKFLJSDFL;KJSDF;LKJSDF;LKSJDFSDFSDFSDFLKJSDLFKSJDFLbytecoder@fireball:~ $ awk '{a=substr($0, 52,4)if (a ~ /MS/ || a ~/MG/ || a ~/SS/ || a ~ /SM/ ||a ~ /AJ/ || a ~/HY/ || a ~/HL/ || a ~ /CC/ ||a ~ /AP/ || a ~/NL/ || a ~/MP/ || a ~ /VT/ ||a ~ /NC/ || a ~/NU/ || a ~/OR/ || a ~ /PO/ ||a ~ /ND/ || a ~/SD/ || a ~/EU/ || a ~ /LT/ ||a ~ /HU/ || a ~/NY/ || a ~/TS/ || a ~ /SO/ ||a ~ /HJ/ || a ~/DO/ || a ~/PI/ || a ~ /PL/ ||a ~ /AT/ || a ~/AV/ || a ~/MB/ || a ~ /MW/ ||a ~ /MO/ || a ~/ML/ || a ~/MH/ || a ~ /MN/ )print}' testbytecoder@fireball:~ $ echo $?0
I can't tell if it does what it's supposed to, but it doesn't give me any errors (the output is empty).
Quote: Original post by cucubird
It will give me an error such as invalid syntax at line 3.4.5 etc...
In addition,I will get an error bailing out message near the last line...which is print}' $src_file > $tmp_file
I get no error just cutting and pasting your awk script. It appears, however, that you are running it from within a shell script, and I believe your errors are coming from the shell, not from awk. Perhaps using on e of the shell-scripting debugging techniques (eg. set -x) will produce more clues.
Stephen M. Webb
Professional Free Software Developer
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement