csh question

Maarten Litmaath maart at cs.vu.nl
Tue Jul 10 04:28:50 AEST 1990


In article <1990Jul09.150046.4238 at virtech.uucp>,
	wonus at virtech.uucp (Kevin C. Wonus) writes:
)In article <7267 at large.cray.com> tbc at large.cray.com (Tom Craig) writes:
)>I have a csh question. Is it possible to redirect stdout and stderr to 
)>different files in the c shell, (like 1>out 2>err in the bourne shell)?
)
)Yes:
)	(program_name > output) >& error
)
)'>&' operator redirects stdout and stderr.  Therefore, stdout must be
)redirected
)first and is enclosed in () for that reason.  After stdout is redirected, the
)'>&' operator redirects only stderr.

Right answer, wrong logic.
First we create a subshell whose stdout _and_ stderr have been redirected
to the file `error'.  _In_ the subshell we execute `program_name' with its
stdout redirected to the file `output'; we don't mess with its stderr, so
that'll still be connected to `error'.  The result of it all is stdout
going to `output' and _only_ stderr going to `error'.  QED
--
 "and with a sudden plop it lands on usenet.  what is it? omigosh, it must[...]
   be a new user! quick kill it before it multiplies!"      (Loren J. Miller)



More information about the Comp.unix.questions mailing list