home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / shell / 4634 < prev    next >
Encoding:
Text File  |  1992-11-10  |  1.4 KB  |  40 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!think.com!sdd.hp.com!zaphod.mps.ohio-state.edu!darwin.sura.net!eng.ufl.edu!news
  3. From: ruck@zeta.ee.ufl.edu (John R Ruckstuhl Jr)
  4. Subject: Bourne shell I/O
  5. Message-ID: <1992Nov10.235519.3857@eng.ufl.edu>
  6. Sender: news@eng.ufl.edu (Usenet Diskhog System)
  7. Organization: EE Dept at UF
  8. Date: Tue, 10 Nov 92 23:55:19 GMT
  9. Lines: 29
  10.  
  11. On several occasions, I've seen posters to comp.unix.shell claim that
  12. there is no need to create temporary files in Bourne shell scripts --
  13. that proper use of redirection and the available file descriptors 
  14. (0-9 ?) are a better way to shuffle temporary data.
  15.  
  16. I'm studying the man pages and I'm having trouble seeing how this works.
  17.  
  18. Suppose I want to process stderr, then process stdout
  19. The solutions I see must use a tempfile.
  20.  
  21. e.g.:
  22.  
  23. $ (echo one >&1; echo two >&2) 2>&1 > tempfile | sed 's/^/stderr /'
  24. stderr two
  25. $ sed 's/^/stdout /' tempfile
  26. stdout one
  27. $ rm tempfile
  28.  
  29. Do any of you know how to use redirection cleverly to avoid creating 
  30. (explicitly) tempfiles?
  31. Or do you think I've misunderstood what the posters meant.
  32. Heck, there must be a reason for the extra file descriptors, right?
  33.  
  34. Thanks very much,
  35. ruck
  36. -- 
  37. John R. Ruckstuhl, Jr.                  ruck@alpha.ee.ufl.edu
  38. Dept of Electrical Engineering          ruck@cis.ufl.edu, uflorida!ruck
  39. University of Florida                   ruck%sphere@cis.ufl.edu, sphere!ruck
  40.