Re: Redirecting stdout and stderr into a file
Otto Wyss wrote: Ben Hutchings <[EMAIL PROTECTED]> wrote: but how can I redirect both together? cat foo 2>&1 > logfile or, to append to the file: cat foo 2>&1 >> logfile Should do it. Redirections are processed in the order they appear on the command line. So "2>&1 >logfile" redirects stderr to the same as current stdout (normally the terminal) and then redirects stdout to logfile. You need to swap the two redirections to send both streams to logfile. grep > 2>&1 logfile Sorry does not work (syntax error near unexpected token '2'). O. Wyss Try: grep >logfile 2>&1 -Roberto Sanchez -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
On Wed, 10 Nov 2004 09:20:29 -0800 (PST), "Sergio Basurto" wrote: > > On Wed, 10 Nov 2004 10:03:17 -0700, Rob Sims wrote: > > > > > On Wednesday 10 November 2004 09:36 am, Otto Wyss > wrote: > > > Blake Swadling <[EMAIL PROTECTED]> wrote: > > > > > but how can I redirect both together? > > > > > > > > grep 2>&1 logfile > > > > > > Sorry does not work, stderr comes still on the > > terminal. > > > > command > logfile 2>&1 > > -- > > Rob > > > > The command is: > > #command 2>./logfile Sorry bad reference, I understand that you want to send stderr to a file, but the command to send stdout & stderr to a file is #command 2>&1> ./logfile Hope this help. -- Sergio Basurto J. If I have seen further it is by standing on the shoulders of giants. (Isaac Newton) -- -- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
On Wed, 10 Nov 2004 10:03:17 -0700, Rob Sims wrote: > > On Wednesday 10 November 2004 09:36 am, Otto Wyss wrote: > > Blake Swadling <[EMAIL PROTECTED]> wrote: > > > > but how can I redirect both together? > > > > > > grep 2>&1 logfile > > > > Sorry does not work, stderr comes still on the > terminal. > > command > logfile 2>&1 > -- > Rob > The command is: #command 2>./logfile you are saying with the "2" you are telling stderr. Regards. -- Sergio Basurto J. If I have seen further it is by standing on the shoulders of giants. (Isaac Newton) -- -- -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
On Wednesday 10 November 2004 18:03, Rob Sims wrote: > > Blake Swadling <[EMAIL PROTECTED]> wrote: > > > > but how can I redirect both together? > command > logfile 2>&1 man bash has a chapter for redirection (starting at line 1426!) For example, it reports the following commands: ls > logfile 2>&1 will redirect both sdtout and stderr, while ls 2>&1 > logfile will only redirect stdout to logfile... Gregor -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
On Wednesday 10 November 2004 09:36 am, Otto Wyss wrote: > Blake Swadling <[EMAIL PROTECTED]> wrote: > > > but how can I redirect both together? > > > > grep 2>&1 logfile > > Sorry does not work, stderr comes still on the terminal. command > logfile 2>&1 -- Rob -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
Ben Hutchings <[EMAIL PROTECTED]> wrote: > >> but how can I redirect both together? > >> > >> > > cat foo 2>&1 > logfile > > or, to append to the file: > > cat foo 2>&1 >> logfile > > > > Should do it. > > Redirections are processed in the order they appear on the command line. > So "2>&1 >logfile" redirects stderr to the same as current stdout > (normally the terminal) and then redirects stdout to logfile. You need > to swap the two redirections to send both streams to logfile. > grep > 2>&1 logfile Sorry does not work (syntax error near unexpected token '2'). O. Wyss -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
Upayavira <[EMAIL PROTECTED]> wrote: > >but how can I redirect both together? > > > > > cat foo 2>&1 > logfile > or, to append to the file: > cat foo 2>&1 >> logfile > Sorry, does not work, both still comes on the terminal. O. Wyss -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
Thomas Adam <[EMAIL PROTECTED]> wrote: > > grep 2>&1 logfile > > grep 'whatever' > ./file 2>&1 > > is what you meant. > Thanks Thomas, this works. O. Wyss -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
Blake Swadling <[EMAIL PROTECTED]> wrote: > > but how can I redirect both together? > > > > grep 2>&1 logfile > Sorry does not work, stderr comes still on the terminal. O. Wyss -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
Upayavira wrote: Otto Wyss wrote: Sorry I can't remember how I can redirect the stdout and stderr together into a file. I can grep > logfile grep 2> logfile but how can I redirect both together? cat foo 2>&1 > logfile or, to append to the file: cat foo 2>&1 >> logfile Should do it. Redirections are processed in the order they appear on the command line. So "2>&1 >logfile" redirects stderr to the same as current stdout (normally the terminal) and then redirects stdout to logfile. You need to swap the two redirections to send both streams to logfile. Ben. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
Otto Wyss wrote: Sorry I can't remember how I can redirect the stdout and stderr together into a file. I can grep > logfile grep 2> logfile but how can I redirect both together? cat foo 2>&1 > logfile or, to append to the file: cat foo 2>&1 >> logfile Should do it. Regards, Upayavira -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
--- Blake Swadling <[EMAIL PROTECTED]> wrote: > grep 2>&1 logfile grep 'whatever' > ./file 2>&1 is what you meant. -- Thomas Adam = "The Linux Weekend Mechanic" -- http://linuxgazette.net "TAG Editor" -- http://linuxgazette.net " We'll just save up your sins, Thomas, and punish you for all of them at once when you get better. The experience will probably kill you. :)" -- Benjamin A. Okopnik (Linux Gazette Technical Editor) ___ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Redirecting stdout and stderr into a file
On Tue, 2004-11-09 at 23:50 +0100, Otto Wyss wrote: > Sorry I can't remember how I can redirect the stdout and stderr together > into a file. I can > > grep > logfile > grep 2> logfile > > but how can I redirect both together? > grep 2>&1 logfile Cheers Blake -- Blake Swadling Senior Software Engineer Newton Pty Ltd Telephone: +61 2 6247 3544 Fax:+61 2 6247 3533 Mobile: +61 407 026277 Web:http://www.newton.com.au signature.asc Description: This is a digitally signed message part