For Programmers: Free Programming Magazines  


Home > Archive > AWK > February 2005 > pipelines and output out of order









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author pipelines and output out of order
Robert Katz

2005-02-26, 3:55 pm

I have an awk program which has UNIX programs piped to getline, and some
of those have other UNIX programs also piped to getline -- nesting.
When I run the program, I get the correct output on the terminal, but
when I look at the output after I've redirected it to a file, some lines
appear in the wrong order. I suppose it has something to do with
closing pipes (I've closed every one and tried different orders), but
I'm still getting transposed lines. Why would they be in the right
order on the terminal, but transposed in a redirected file? Any thoughts?

--
Regards,

---Robert
Robert Katz

2005-02-26, 8:55 pm

Robert Katz wrote:
> I have an awk program which has UNIX programs piped to getline, and some
> of those have other UNIX programs also piped to getline -- nesting. When
> I run the program, I get the correct output on the terminal, but when I
> look at the output after I've redirected it to a file, some lines appear
> in the wrong order. I suppose it has something to do with closing pipes
> (I've closed every one and tried different orders), but I'm still
> getting transposed lines. Why would they be in the right order on the
> terminal, but transposed in a redirected file? Any thoughts?
>


Okay, well I did the obvious first step -- replaced the default awk with
gawk, and all's well. But my question remains, what the heck is the
original awk doing that gives valid output on the terminal, but
transposes lines when redirecting the output to a file?

$ awkprog ##valid output
$ awkprog > file ##file has some lines transposed
$ awk 'NR == 1' awkprog
#!/usr/bin/awk -f

--
Regards,

---Robert
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com