home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / question / 13473 < prev    next >
Encoding:
Internet Message Format  |  1992-11-16  |  1.1 KB

  1. Path: sparky!uunet!ukma!darwin.sura.net!dtix!mimsy!afterlife!adm!news
  2. From: partl@hp01.boku.ac.at (Hubert Partl)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: problems with awk: output redirection and getline in a pipe
  5. Message-ID: <34103@adm.brl.mil>
  6. Date: 16 Nov 92 09:28:57 GMT
  7. Sender: news@adm.brl.mil
  8. Lines: 18
  9.  
  10. > awk 'BEGIN {print "...something"}
  11. >            {print " ...anything for every line"}
  12. >     END    {printf("%2d\n", NR) >"awk.tmp" }' |
  13. > sort |
  14. > awk 'BEGIN {getline < "awk.tmp";
  15. >            numberoflines = $1}
  16. >            {print "---anything for every line"}
  17. >      END   {printf("%2d\n", numberoflines)} '
  18.  
  19. All three processes of the pipe  "awk | sort | awk"   are running in
  20. parallel, the last awk starts BEFORE the first awk has ended and
  21. therefore reads an old awk.tmp, not the new one.
  22.  
  23. --
  24. Dr. Hubert Partl                              Mail:  partl@mail.boku.ac.at
  25. EDV-Zentrum, Universitaet fuer Bodenkultur    Phone: (+43 1) 36 92 924 - 233
  26. Nussdorfer Laende 11                          Fax:   (+43 1) 36 92 924 - 200
  27. A-1190 Wien, Austria                          (-:  Make laugh, not war!  :-)
  28.