AWK: Problem processing first line 
Author Message
 AWK: Problem processing first line

I work on PC with MKS Toolkit. I noticed awk has problem processing the
first line of a file. Work-around on UNIX was to use nawk instead.
But I didn't find any nawk to install on PC.

Could anyone help?

Thanks

jpf



Sun, 13 Jan 2002 03:00:00 GMT  
 AWK: Problem processing first line

Quote:

> I work on PC with MKS Toolkit. I noticed awk has problem processing the
> first line of a file. Work-around on UNIX was to use nawk instead.
> But I didn't find any nawk to install on PC.

MKS awk _is_ "nawk to install on PC."

I've used MKS awk for a very long time and have never noticed that
it has a "problem processing the first line of a file." It's more
likely the problem is with your script and/or your understanding
of awk. But you didn't post any example code, so we'll never know...

By the way, this script is wrong:

    { FS = ","; foo = $1; print foo }

And this script is right:

    BEGIN { FS = "," } { foo = $1; print foo }

Just in case _that_ is what you did that caused you to think awk
was not parsing the first record correctly...

--
Jim Monty

Tempe, Arizona USA



Sun, 13 Jan 2002 03:00:00 GMT  
 AWK: Problem processing first line


   >I work on PC with MKS Toolkit. I noticed awk has problem processing
   >the first line of a file. Work-around on UNIX was to use nawk
   >instead. But I didn't find any nawk to install on PC.
   >Could anyone help?
   >Thanks
   >jpf
Could you give an example of the problem?
Is it that your version of awk does not have the FNR variable?
One possible workaround for that is to test for the start of a file with
FILENAME!=oldfile { do stuff; oldfile=FILENAME }
Gawk is available for DOS and Windows, it is newer and more advanced than nawk.

Net-Tamer V 1.08X - Test Drive



Sun, 13 Jan 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. awk first word on first line

2. AWK question: first line that matches?

3. first line not processed

4. processing one line in a file at a time using awk

5. awk/gawk stop after processing 40mill lines

6. awk process in awk ??

7. Selecting first line on screen and current line after reread in browselist

8. text widget, how to get line number of first line displayed

9. awk -- pattern match a line and the line that follows

10. Output from AWK script contains original input lines *AND* post-processed lines!! HELP!!

11. My first awk program

12. first time awk

 

 
Powered by phpBB® Forum Software