[BLUG] Bash stdout duplicated to a file

Gaddis, Jeremy L. blug_at_mailman.cs.indiana.edu
Tue, 27 Feb 2007 14:35:48 -0500


$ tee --help
Usage: tee [OPTION]... [FILE]...
Copy standard input to each FILE, and also to standard output.

  -a, --append              append to the given FILEs, do not overwrite
  -i, --ignore-interrupts   ignore interrupt signals
      --help     display this help and exit
      --version  output version information and exit

If a FILE is -, copy again to standard output.

Report bugs to <bug-coreutils_at_gnu.org>. 


--
Jeremy L. Gaddis
Network Administrator
812.330.6156 (w)  812.391.0358 (m)
 

-----Original Message-----
From: blug-admin_at_cs.indiana.edu [mailto:blug-admin_at_cs.indiana.edu] On
Behalf Of Chris Colvard
Sent: Tuesday, February 27, 2007 2:33 PM
To: blug_at_cs.indiana.edu
Subject: [BLUG] Bash stdout duplicated to a file

I should know how to do this, but I'm having trouble getting stdout to 
go to BOTH stdout and a file in a bash script.

For example, I have the following script
> #!/bin/bash
>
> exec 3>test.log
> exec >&3
> echo "Test"
This will print "Test" to test.log, but not to stdout.  It seems that 
stdout is redirected to fd3 instead of being duplicated to fd3.
Is there a way to print to both stdout and a file at the same time?

Thanks,
Chris Colvard

_______________________________________________
BLUG mailing list
BLUG_at_linuxfan.com
http://mailman.cs.indiana.edu/mailman/listinfo/blug