ron
Member
I hope there is a Unix guru out there who can help me.
I've written a number of awk scripts before OK, but I'm stuck on a simple but aggravating issue.
I've cut the code down to just a small test snippet:
The testfile is a copy of an OE10 db.lg file (not that that's important). The above code works - and produces 8 lines of output, as it should. However, if I change the syntax of the last statement to make it an if statement - I get a syntax error:
Can someone explain what I'm doing wrong? I've used if statements before without a problem - but now ... I'm stuck.
Ron.
I've written a number of awk scripts before OK, but I'm stuck on a simple but aggravating issue.
I've cut the code down to just a small test snippet:
Code:
#!/bin/ksh93
cat /tmp/testfile | awk 'BEGIN { count = 0; }
/\(3777\)/ { print substr( $0, 66, 20); count++ };
count > 7 { exit };
'
The testfile is a copy of an OE10 db.lg file (not that that's important). The above code works - and produces 8 lines of output, as it should. However, if I change the syntax of the last statement to make it an if statement - I get a syntax error:
Code:
#!/bin/ksh93
cat /tmp/testfile | awk 'BEGIN { count = 0; }
/\(3777\)/ { print substr( $0, 66, 20); count++ };
if ( count > 7 ) { exit };
'
Code:
/tmp > t
syntax error The source line is 5.
The error context is
>>> if <<< ( count > 7 ) { exit };
awk: Quitting
The source line is 5.
Can someone explain what I'm doing wrong? I've used if statements before without a problem - but now ... I'm stuck.
Ron.