Article View: comp.unix.programmer
Article #146Re: NAWK - ?Diff. printf output order when using a pipe.
From: John H. Merritt
Date: Mon, 27 Jul 1992 23:14
Date: Mon, 27 Jul 1992 23:14
34 lines
2085 bytes
2085 bytes
In article <1992Jul26.221156.12144@nsisrv.gsfc.nasa.gov>, merritt@climate.gsfc.nasa.gov (John H. Merritt) writes:
|> 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");
system("fflush()")
|> |> }
[...]
|> 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.
Ha! Completely by accident and totally by surprise, adding
'system("fflush()")' in the BEGIN section works! Now, really, I do
know what that statement is trying to do. As it turns out, anything
in the system call will produce the results I was looking for. Anything,
that is, that doesn't echo a 'command not found' or other such message.
What better function to define than one that self documents. :-)
This solution was discovered by a beginner who had
no clue about the difference between commands in
section 1 and functions in section 3. Kind of a good thing
that 'system' invokes '/bin/sh'.
--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
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:
<1992Jul27.231423.15827@nsisrv.gsfc.nasa.gov>Path:
arc1-ca.pugleaf.net!sparky!uunet!decwrl!sdd.hp.com!uakari.primate.wisc.edu!ames!nsisrv!climate.gsfc.nasa.gov!merrittReferences:
<1992Jul26.033811.21614@nsisrv.gsfc.nasa.gov> <1992Jul26.221156.12144@nsisrv.gsfc.nasa.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!decwrl!sdd.hp.com!uakari.primate.wisc.edu!ames!nsisrv!climate.gsfc.nasa.gov!merritt From: merritt@climate.gsfc.nasa.gov (John H. Merritt) Newsgroups: comp.unix.programmer Subject: Re: NAWK - ?Diff. printf output order when using a pipe. Message-ID: <1992Jul27.231423.15827@nsisrv.gsfc.nasa.gov> Date: 27 Jul 92 23:14:23 GMT References: <1992Jul26.033811.21614@nsisrv.gsfc.nasa.gov> <1992Jul26.221156.12144@nsisrv.gsfc.nasa.gov> Sender: usenet@nsisrv.gsfc.nasa.gov (Usenet) Organization: Climate and Radiation Branch Lines: 34 Nntp-Posting-Host: climate.gsfc.nasa.gov