1 hour ago · 7 min read1483 words · Tech · hide · Fediverse post

I have spent hours on this problem more than once. I hope this saves someone from a bad afternoon.The problemWe are used to piping things to grep or sed, and getting output.But, sometimes, the source isn't a list of lines. Sometimes, the text you want to run a regex replace on is a stream. Two real-life examples:A stream of dictated textStreamed output from Llama.cpp serverHere, we run into two issues:Many coreutils buffer input and/or outputMany of the Unix coreutils operate on lines by default. Sed is the most obvious example.Test caseHere's an example that will let us test our solutions, and prove that most of them don't work.Create a file:touch /tmp/realtimestreamNow, tail it:tail -f /tmp/realtimestreamNow, in a new terminal, append something to it, without a newline:echo -n "Hello, tail. How are you?" >> /tmp/realtimestream ... and watch it arrive in terminal #2, as intended, the moment you hit enter.Now, open another terminal, and try to filter the output of tail in…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town