[BLUG] Bash stdout duplicated to a file

Chris Colvard blug_at_mailman.cs.indiana.edu
Tue, 27 Feb 2007 14:32:47 -0500


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