thanks all for answering, now i get it ( i think  )

btw: can i exchange stderr and stdout  ? ( 2>1 1>2 ? )
what does the '&' stand for in the "2>&1" can i do 2>1 ? what is the 
difference ?

Oleg Goldshmidt wrote:

>Alex Shnitman <[EMAIL PROTECTED]> writes:
>
>>On Thu, 2002-09-12 at 16:03, [EMAIL PROTECTED] wrote:
>>
>>>i want to redirect both strdout and stderror into a pipe
>>>
>>>in tcsh i do: process1 |& process2
>>>how do i do it in sh ? in bash ? ( is that the same )
>>>
>>process1 2>&1 | process2
>>
>
>Note that this is not exactly what the OP asked for. What 2>&1 does
>is duplicates stderr to stdout, and then redirects stdout *only* to
>the pipe. See man bash for details.
>
>I suspect that the proper answer is
>
>process1 | 2>&1 process2
>
>Subtle details can be shown using the trivial
>
>#include <stdio.h>
>
>int main(void)
>{
>       fprintf(stdout,"stdout\n");
>       fflush(0);
>       fprintf(stderr,"stderr\n");
>       fflush(0);
>       return 0;
>}
>
>$ a.out 2>&1 | cat 
>stdout
>stderr
>$ a.out | 2>&1 cat 
>stderr
>stdout
>$ a.out 2>/dev/null 2>&1 | cat 
>stdout
>stderr
>$ a.out 2>/dev/null | 2>&1 cat 
>stdout
>
>On the other hand, maybe "process1 2>&1 | process2" is exactly what
>the OP wanted, it was not quite clear. I just thought one should be
>aware of the difference.
>


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to