[TriLUG] block versus line buffering for stdout in bash

Marc Wiatrowski mwia at iglass.net
Mon Jul 7 16:18:34 EDT 2008


What happens if you dup stdout to stderr?   1>&2

On Mon, 2008-07-07 at 14:03 -0400, Andrew Ball wrote:

> bash switches to block-based buffering rather than line buffering when
> stdout is redirected.  Does anyone know of a way to get it to not do
> block buffering?  I keep getting output mixed in odd ways when I do
> something like 'python script_that_uses_both_stderr_and_stdout 2>&1'.
> It makes to get all of at least lots of stderr output before stdout,
> but it's annoying when I want the data to appear more or less
> synchronously.
> 
> There's a python flag '-u' that makes everything unbuffered, which
> does the trick for Python scripts, but I'm curious as to whether
> there's a general solution with bash.
> 
> Peace,
> Andrew
> 
> -- 
> =======================
> Andrew D. Ball
> 勃安
> deus caritas est
> http://www.ibiblio.org/adball/blog/
> http://filebox.vt.edu/~anball1/



More information about the TriLUG mailing list