> For example, it's typical text processing pipelines are hard to branch.
I'm not entirely sure what you mean by this, but it sounds like you should use "tee" pointing at a fifo.
I'm not entirely sure what you mean by this, but it sounds like you should use "tee" pointing at a fifo.
How to do it without iterating the file 2 times? You can do while of course, but it defeats the reason to use shell.
I would love to have two-way grep that writes matching lines to stdout and nonmatching to stderr. I wonder if grep maintainers would accept new option for grep "--two-way".
Personally though, I'd output to temporary files. The extra cost in disk usage and lack of pipelining is made up for by the easier debugging, and most shell pipelines aren't so slow that they need that level of optimization.