V Kumar
V Kumar

Reputation: 61

awk syntax and illegal statement error

I'm getting syntax error for below line. Not sure what is the syntax error.

bash-3.2$ awk -F"|" '{ if ($4 != "N.A." && $29 =="1") printf("%s|testfile\n", $4) >> "out1.txt" else if ($4 != "N.A." &&  $29 =="2A") printf("%s|testfile\n", $4) >> "out2.txt" }' infile
awk: syntax error near line 1
awk: illegal statement near line 1

Upvotes: 1

Views: 1184

Answers (2)

null
null

Reputation: 473

I think you're just missing ; after "out1.txt"

Upvotes: 1

Ed Morton
Ed Morton

Reputation: 203219

You're using old, broken awk (/bin/awk on Solaris). On Solaris use /usr/xpg4/bin/awk.

Upvotes: 1

Related Questions