In my experience with this problem, it appears that buffering issues can affect both the read and write sides of each command. In my case, I had a command like the following:
$ parallel ... | ggrep ...
This worked fine, printing output as it was produced by parallel
. When I tried to process further with awk
, though:
$ parallel ... | ggrep ... | awk ...
I didn't see output until parallel
was done. I naturally thought the issue was with awk
, hence finding this post, so I tried this:
$ parallel ... | ggrep ... | stdbuf -o0 awk ...
But what actually fixed it was this:
$ parallel ... | stdbuf -o0 ggrep ... | awk ...
So it appears that ggrep
can tell when it's printing vs. hooked up to another command, and buffers its output in the latter case. (Incidentally, ggrep
actually has a --line-buffered
flag which fixes my problem as well.)