A quick explanation in case anyone else wants to know why this works:

this part "3>&1 1>&2 2>&3" swaps stderr and stdout (so errors show up on stdout 
and non-errors show up on stderr)
then tee copies the *swapped* stdout to the file /tmp/junk.err, so error 
messages end up there
both stdout and stderr are then copied to junk.log ({>&} copies both outputs to 
one file), it doesn't care that they're
swapped around.

[email protected] wrote:
> I'm not quite sure how it works, bit it does exactly what I want...   :) 
> 
> 
> srcad...@mothership[~]$ cat /tmp/junk.sh
> #!/bin/bash 
> 
> echo "GOOD boy..."
> echo "MORON BOY!!" >&2
> #END#
> srcad...@mothership[~]$ rm -f /tmp/junk.err /tmp/junk.log
> srcad...@mothership[~]$ ((/tmp/junk.sh 3>&1 1>&2 2>&3) | tee /tmp/junk.err) 
>> & /tmp/junk.log
> srcad...@mothership[~]$ cat /tmp/junk.log
> GOOD boy...
> MORON BOY!!
> srcad...@mothership[~]$ cat /tmp/junk.err
> MORON BOY!!
> srcad...@mothership[~]$
> ---------------------------------------------------
> PLUG-discuss mailing list - [email protected]
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
> 
---------------------------------------------------
PLUG-discuss mailing list - [email protected]
To subscribe, unsubscribe, or to change your mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss

Reply via email to