Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!batcomputer!itsgw!steinmetz!ge-dab!peora!rtmvax!mjg From: mjg@rtmvax.UUCP (Mike Gogulski) Newsgroups: comp.unix.questions Subject: Re: C shell question. Keywords: standard error, output redirection. Message-ID: <2904@rtmvax.UUCP> Date: 13 Feb 89 03:41:21 GMT References: <6295@phoenix.Princeton.EDU> Reply-To: mjg@rtmvax.UUCP (Mike Gogulski) Organization: Infinity, Ltd. Lines: 47 In article <6295@phoenix.Princeton.EDU> prnott@phoenix.Princeton.EDU () writes: > > I hope this is the right news-group for this question - >Could someone tell me how I can redirect output from standard error >to a file or device? In the Bourne shell, this can be achieved by > > command 2>filename, but this doesn't work in the C shell. > >Does anyone know what the syntax is? Thanks in advance. > >Prabhu. Well, the syntax is is pretty simple. You can direct the stdout with the following: % command > file You redirect the standard error in the same way. % command >& file <-- this puts BOTH the stderr and the stdout into 'file.' These work with >> and >>& as well, for 'append to file.' However, there is no easy way in csh to duplicate th effects of the following sh command: $ command 1>stdout 2>stderr, because csh does either the stdout or both the stdout and the stderr. If you want to put the stdout in one file and the stderr in another, the way to go is something like this: % ( command > stdout ) >& stderr This, however, is kinda yucky. You might wish to look at Bob Glickstein's "redir" program, recently posted to comp.sources.misc, which allows redirection much like sh does. --Mike +-----------------------------------------------------------------------------+ | DISCLAIMER: | Mike ...{uiucuxc|petsd}!peora!ucf-cs!ucfunix!mjg| | I Am _NOT_ The Walrus | Gogulski ...{uiucuxc|petsd}!peora!rtmvax!mjg | +-----------------------------------------------------------------------------+ | "The number of UNIX installations has grown to 10, with more expected." | | (The _UNIX Programmer's Manual_, 2nd Edition, June, 1972.) | +-----------------------------------------------------------------------------+