help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] shell redirection


From: Greg Wooledge
Subject: Re: [Help-bash] shell redirection
Date: Wed, 19 Oct 2016 14:09:49 -0400
User-agent: Mutt/1.4.2.3i

On Wed, Oct 19, 2016 at 07:28:24PM +0200, Christof Warlich wrote:
> I want my script(s) to print stderr to the terminal, while both stdout 
> _/and/_ stderr should go to a logfile.

Not possible without hacks that will break synchronization between the
streams.

> Any ideas how this could be done, ideally without using any temporary 
> files or named pipes?

A temp file probably wouldn't help, because you'd lose *all* sync
information.  Instead of having

stdOut1
stdErr1
O2
E2

you'd end up with

O1
O2
O3
E1
E2
E3

Probably not what you want.

You could set up two piped readers, one for each stream, and have them
both write to your log file (opened in *append* mode by each one).
Then the stderr reader (but not the stdout reader) would also write
to the terminal.

So, two process substitutions (which are roughly equivalent to named
pipes), and each one is reading in (presumably) a line-oriented way.
That's the best you're likely to get.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]