[X-Unix] Question about using RsyncX

David Ledger dledger at ivdcs.demon.co.uk
Sun Feb 1 09:13:24 PST 2004


>From: Brian Medley <bpm-list-osx-unix at 4321.tv>
>On Thu, Jan 29, 2004 at 07:37:28PM -0500, Our Pal Al wrote:
>
>>  I could redirect the output into a file no problem but don't know how to
>>  "bi-direct" it to screen AND file.  Can anybody tell me how?
>
>$ echo `uname -a` 2>&1 | tee ~/uname.output
>Darwin snafu.local 7.2.0 Darwin Kernel Version 7.2.0: Thu Dec 11 
>16:20:23 PST 2003; root:xnu/xnu-517.3.7.obj~1/RELEASE_PPC Power 
>Macintosh powerpc

echo `uname -a` 2>&1 | tee ~/uname.output
takes the stdout of the uname command and saves it in a buffer.  Any 
stderr o/p that uname might produce goes to wherever stderr goes. 
The echo then puts the contents of the buffer onto stdout.  The 2>&1 
joins the stderr *of the echo command* into stdout.

uname is unlikely to produce anything on stderr, but if we regard it 
as just an example, the above doesn't do  what the left half is 
intended to do.  To join the streams just do
uname -a 2>&1 | tee ~/uname.output
Where the stderr appears in the stdout stream depends on buffering 
and is not easy to predict.

For a real example try (where /fred doesn't exist)
ls /private /fred 2>&1 | tee /tmp/list
then
cat /tmp/list
(and then    rm /tmp/list   to tidy up).

David


-- 
David Ledger - Freelance Unix Sysadmin in the UK.
Chair of HPUX SysAdmin SIG of hpUG technical user group (www.hpug.org.uk)
dledger at ivdcs.co.uk (also dledger at ivdcs.demon.co.uk)
www.ivdcs.co.uk



More information about the X-Unix mailing list