home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 3926 < prev    next >
Encoding:
Text File  |  1992-07-26  |  1.8 KB  |  50 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!sun-barr!ames!nsisrv!climate.gsfc.nasa.gov!merritt
  3. From: merritt@climate.gsfc.nasa.gov (John H. Merritt)
  4. Subject: Re: NAWK - ?Diff. printf output order when using a pipe.
  5. Message-ID: <1992Jul26.221156.12144@nsisrv.gsfc.nasa.gov>
  6. Sender: usenet@nsisrv.gsfc.nasa.gov (Usenet)
  7. Nntp-Posting-Host: climate.gsfc.nasa.gov
  8. Organization: Climate and Radiation Branch
  9. References:  <1992Jul26.033811.21614@nsisrv.gsfc.nasa.gov>
  10. Date: Sun, 26 Jul 1992 22:11:56 GMT
  11. Lines: 37
  12.  
  13. In article <1992Jul26.033811.21614@nsisrv.gsfc.nasa.gov>, merritt@climate.gsfc.nasa.gov (John H. Merritt) writes:
  14. |> Explain why the following 'nawk' program produces:
  15. [ output deleted ]
  16.  
  17. |> Here is the program:
  18. |> ---- cut test.nawk ----
  19. |> BEGIN {
  20. |>     printf("This is the BEGIN section\n");
  21. |> }
  22. |> 
  23. |>     { printf("%s %s %s\n",$1,$2,$3) | "cat" }
  24. |> 
  25. |> END {
  26. |>     close("cat")
  27. |>     printf("This is the END section\n");
  28. |> }
  29.  
  30. Already there is misunderstanding about what I want in the way of answers.
  31. I want a solution to getting the same output when seeing the output
  32. at the terminal or redirecting it to a file.  Answers of the form:
  33. "Don't pipe it into cat." are not what I want to see.  In my real problem,
  34. I am piping the output into sort (or anything else) and the BEGIN and
  35. END sections are more complicated.  This example was the
  36. shortest nawk program which illustrates the problem.
  37.  
  38. I WANT THE PIPE TO REMAIN.
  39.  
  40. If there is something like 'fflush' in AWK, that would be great.
  41. So far 'close' was the closest thing I found, but the exact syntax eludes
  42. me -- if it is the right thing at all.
  43.  
  44.  
  45. -- 
  46. \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
  47. John H. Merritt --> merritt@climate.gsfc.nasa.gov
  48. "I am generally intolerant of ignorance,
  49. but I have made an exception in your case."
  50.