Re: Redirecting stdout and stderr into a file
Ben Hutchings <ben.hutchings@businesswebsoftware.com> 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
Reply to: