|
From: | Yan Seiner |
Subject: | Re: weird bash pipe behavior |
Date: | Thu, 21 Jan 2010 06:11:10 -0800 |
User-agent: | Mozilla-Thunderbird 2.0.0.19 (X11/20090103) |
Greg Wooledge wrote:
That is the correct solution. Apparently the behavior is not limited to grep; any process in a pipe that's longer than 2 can exhibit this. Something about libc behavior...On Wed, Jan 20, 2010 at 07:34:35AM -0800, CptDpondo wrote:mencoder .... 2>&1 | tr '\r' '\n' | grep -v -B 1 '^Pos' this eventually creates the correct output, but it's buffered until mencoder completes. I have no idea why; the tr command streams without buffering and I've used grep for years and never run into this behavior.grep definitely has this buffering behavior. If you're using GNU grep, you can give it the --line-buffered option to change this, at least according to whichever contributor added that one to http://mywiki.wooledge.org/BashFAQ/009
I replaced grep with awk, ran in to the same problem, and ended up using fflush() after scanning each line.
Interesting. I learned something today. -- o__ ,>/'_ o__ (_)\(_) ,>/'_ o__ A day may come (_)\(_) ,>/'_ o__when the courage of men fails, (_)\(_) ,>/'_ when we forsake our friends and break all (_)\(_)
bonds of fellowship, but it is not this day. It is not this day! This day we ride!
[Prev in Thread] | Current Thread | [Next in Thread] |