Redirect bash output to new file every 10 seconds

Viewed 702

I have a COM_port, which I listen like this:

nc -l -p 1234.

So, I want to redirect the output to a file, at that every 10 seconds to a new file. I know how to redirect the flow to a file:

nc -l -p 1234 > file.txt

But how to write the flow to new file every 10 seconds? (for first 10 seconds file_10.txt, for second file_20.txt and so on). I'm afraid of loosing the data from flow. How is it possible to do that?

Thanks.

1 Answers
Related