[TriLUG] block versus line buffering for stdout in bash

Andrew Ball anball at gmail.com
Mon Jul 7 14:03:11 EDT 2008


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