Article View: comp.unix.programmer
Article #130Re: NAWK - ?Diff. printf output order when using a pipe.
From: John H. Merritt
Date: Sun, 26 Jul 1992 22:11
Date: Sun, 26 Jul 1992 22:11
37 lines
1853 bytes
1853 bytes
In article <1992Jul26.033811.21614@nsisrv.gsfc.nasa.gov>, merritt@climate.gsfc.nasa.gov (John H. Merritt) writes:
|> Explain why the following 'nawk' program produces:
[ output deleted ]
|> Here is the program:
|> ---- cut test.nawk ----
|> BEGIN {
|> printf("This is the BEGIN section\n");
|> }
|>
|> { printf("%s %s %s\n",$1,$2,$3) | "cat" }
|>
|> END {
|> close("cat")
|> printf("This is the END section\n");
|> }
Already there is misunderstanding about what I want in the way of answers.
I want a solution to getting the same output when seeing the output
at the terminal or redirecting it to a file. Answers of the form:
"Don't pipe it into cat." are not what I want to see. In my real problem,
I am piping the output into sort (or anything else) and the BEGIN and
END sections are more complicated. This example was the
shortest nawk program which illustrates the problem.
I WANT THE PIPE TO REMAIN.
If there is something like 'fflush' in AWK, that would be great.
So far 'close' was the closest thing I found, but the exact syntax eludes
me -- if it is the right thing at all.
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
John H. Merritt --> merritt@climate.gsfc.nasa.gov
"I am generally intolerant of ignorance,
but I have made an exception in your case."
Technical Details
Message-ID:
<1992Jul26.221156.12144@nsisrv.gsfc.nasa.gov>Path:
arc1-ca.pugleaf.net!sparky!uunet!sun-barr!ames!nsisrv!climate.gsfc.nasa.gov!merrittReferences:
<1992Jul26.033811.21614@nsisrv.gsfc.nasa.gov>Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!sun-barr!ames!nsisrv!climate.gsfc.nasa.gov!merritt From: merritt@climate.gsfc.nasa.gov (John H. Merritt) Subject: Re: NAWK - ?Diff. printf output order when using a pipe. Message-ID: <1992Jul26.221156.12144@nsisrv.gsfc.nasa.gov> Sender: usenet@nsisrv.gsfc.nasa.gov (Usenet) Nntp-Posting-Host: climate.gsfc.nasa.gov Organization: Climate and Radiation Branch References: <1992Jul26.033811.21614@nsisrv.gsfc.nasa.gov> Date: Sun, 26 Jul 1992 22:11:56 GMT Lines: 37