Yes, use a daemon program that takes a stream as input and does only what you described. I would recommend C instead of a script, as it has very simple I / O and very low overhead.
Assuming you have an executable file called “capture” and a filter program called “filter”, you can link them together with the bash shell using
bash-prompt$ capture capture-params | filter
, capture stdout, filter stdin. , , ..., ( ). stdout, ,
bash-prompt$ capture capture-params | filter > output-file.txt