[Gllug] redirecting stdout to multiple files

salsaman salsaman at xs4all.nl
Fri Dec 15 16:31:02 UTC 2006


Ben Fitzgerald wrote:

>On Fri, Dec 15, 2006 at 11:43:14AM +0000, - Tethys wrote:
>  
>
>>On 12/15/06, Ben Fitzgerald <ben_m_f at yahoo.co.uk> wrote:
>>
>>    
>>
>>>echo hi | tee /tmp/log.txt
>>>
>>>but just using i/o redirection with a single cmd.
>>>      
>>>
>>Do you have a specific reason for not wanting to just use tee here?
>>    
>>
>
>I want to be able to have a single line that outputs to stdout and a
>logfile without spawning a subshell by using a pipe. I'd imagine this
>kind of thing must be in build scripts? I want two modes, though:
>
>1. output to stdout only
>2. output to stdout and logfile
>
>I +could+ just use tee, it's true but then I'd need two lines, AFAIK:
>
>[ -n "$stdout_only" ] && echo hi
>[ -z "$stdout_only" ] && echo hi | tee -a /tmp/mylog.txt
>
>I had a quick go through the i/o section of the advanced bash scripting
>guide but nothing leapt out at me.
>
>cheers,
>
>ben.
>
>  
>
Why not just:
tail -f logfile.txt &

Then anything sent to logfile.txt will also appear on the terminal.

Gabriel.

-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list