do while loop won't run awk -


i trying grips writing awk scripts, however, i'm running issues do...while loops.

    -bash-3.00$ cat basicloop.awk     begin { count = 1             {             print "stuff"             } while ( count != 1 )     } 

when run it:

-bash-3.00$ awk -f basicloop.awk
awk: syntax error near line 3
awk: illegal statement near line 3
awk: syntax error near line 5
awk: bailing out near line 5

    {         count=1         {             print "i printed @ least once no matter what"          } while ( count != 1 )     } 

awk: syntax error near line 3
awk: illegal statement near line 3
awk: syntax error near line 5
awk: bailing out near line 5

as can see, these both simple do...while loops , don't know why they're running issues. latter taken directly from: http://www.ibm.com/developerworks/library/l-awk2/ , former take on it.

    -bash-3.00$ nawk -f basicloop.awk     stuff 

running exact same files in nawk seems them work fine, however, can seen above , below.

    printed @ least once no matter 

the workaround run them in nawk, i'd sooner understand whatever issue , fix (if possible) rather ignore it.


Comments