How can I capture and filter command output in real-time?
Asked by
_desk lamp
I'm running a long command that produces a huge amount of debug output over several days. I'd like to be able to peek into this output and filter it on the fly since my interests varyโsometimes I'm looking for lines with 'foo,' other times 'bar,' etc. Since it's too much data to redirect to a single file and tail it for specific strings, I'm hoping for a solution that lets me tap into the command's output at any point.
Is there a way to broadcast this output and simultaneously filter out the lines I don't need, perhaps using netcat or similar tools? I'm not very familiar with the netcat family of commands, so I could use some guidance on how to set this up.
Answers
If you're already using tmux, you can detach from your session and then reattach when you want to check the output. Thereโs also a way to pipe the output to filters when you're inside tmux. Give it a try!
Reply to this answer
You can achieve this by using netcat to broadcast the output. For the sender, use: `nc -bu 127.255.255.255 9999` and for the receiver, use: `nc -lu 127.255.255.255 9999`. This method allows you to stream data without missing any packets, and it's fast too!
Reply to this answer
Add your answer
Answers are reviewed before publication.
_desk lamp: I didnโt know tmux could do that! Iโll definitely look into how to filter while inside a session. Thanks!