Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: pipes and redirection



Gerald Skerbitz wrote:
:I've been trying desparately to do something with the shell and failing.
:The goal is to get stdout to go to a file, and stderr to be piped to
:another program.
:If I do this:
:(print -u2 This is stderr;print This is stdout) 2>&1 1>test
:Then the file "test" contains the string "This is stdout"
:and "This is stderr" is printed to the terminal.
:
:So, assuming that the pipe (|) should send the stdout (file descriptor 1) on
:to the program, I tried this:
:(print -u2 This is stderr;print This is stdout) 2>&1 1>test | less
:which brought up less, with _both_ strings displayed.
:So, clearly, the | is picking up both streams.
:Is there a way to cleanly do what I want it to do?

You could always do:
coproc (print -u2 This is stderr;print This is stdout) 2>&p >test ; less <&p
-- 
Geoff Wing [gwing@xxxxxxxxxxxxxxx]     PrimeNet - Internet Consultancy
  Web   : http://www.primenet.com.au/  Phone    : +61-3-9818 2977
  Mobile: 0412 162 441		       Facsimile: +61-3-9819 3788



Messages sorted by: Reverse Date, Date, Thread, Author