home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / question / 13161 < prev    next >
Encoding:
Text File  |  1992-11-09  |  1.3 KB  |  44 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!ferkel.ucsb.edu!piggy!chupchup
  3. From: chupchup@ferkel.ucsb.edu (Robert Earl)
  4. Subject: Re: Standard AND piped input
  5. Message-ID: <Nov.721323995@piggy>
  6. Organization: (EVIL!)
  7. References: <1992Nov9.042122.18966@cs.sandia.gov>
  8. Date: Mon, 9 Nov 1992 15:46:35 GMT
  9. Lines: 33
  10.  
  11. jhgreen@cs.sandia.gov (Jethro H. Greene) writes:
  12.  
  13. | Followup-To: jhgreen@c.sandia.gov
  14.  
  15. This is a nasty followup header; "Followup-To" should either be a
  16. newsgroup name or the word "poster" for mail replies.  My news
  17. software wanted to post this to a newsgroup called
  18. "jhgreen@c.sandia.gov"...
  19.  
  20. | When one pipes to something, the the output of the first becomes the input
  21. | of the second.  What would you do if you wanted the output of the first to
  22. | be only be the beginning of the input for the second.  
  23.  
  24. |     $ ls | thing_that_I_am_looking_for > output_file
  25. |         bob is my dog
  26. |     ^D
  27. |     $ cat output_file
  28. |         file1
  29. |     file2
  30. |     bob is my dog
  31. |     $
  32.  
  33. Try this:
  34.  
  35. $ (ls; cat) > output_file
  36.  
  37. In other words, start a subshell that runs *both* "ls" and "cat", and
  38. redirect the whole shebang to "output_file".
  39.  
  40. -- 
  41. robert earl          |
  42. rearl@ucsd.edu       | "I got a bottle of tequila, baby, who needs friends?"
  43. rearl@piggy.ucsb.edu |   --Johnette Napolitano, Concrete Blonde
  44.