How can I duplicate a pipe stream (output from another program) so that for every line, I can check whether it matches independent regular expressions (ideally, reuse a
grep command with options like
-i etc.) but process results of each expression separately?
I want to define exit code from my
check function as follows:
- no line in stream matches
- at least one line in stream matches
I want to process lines in memory without storing them to file, report exit code and pass original stream to another program using pipes (logging
whitelist matches to
stderr or elsewhere would be useful too).
Usage would look like:
fetch-big-stream | check whitelist blacklist | cat exitcode=$?
fork duplicates lines,
blacklist are functions and
check passess copy of stream to each separately and terminates once exitcode can be determined before
EOF. There is also a problem with
| implementation that does not propagate non-zero code.