0

I need to read data sent by UDP. I use nc -ul 50000. It keeps running even after having received a line. I want to read every line as it arrives. How can I do that?

An answer to another question on Stackexchange suggested using something like

while read VAR
do
my_command
done < <(nc -ul 50000)

but that doesn't do the trick... doesn't read anything. I am really grateful for any help you can provide cause I really don't know how this could be done.

  • See also: https://stackoverflow.com/questions/11337041/force-line-buffering-of-stdout-when-piping-to-tee – cdarke Feb 15 '18 at 09:04

1 Answers1

1

You can force a program to use line-buffered or unbuffered output with

stdbuf -o L nc -ul 50000

(replace the "L" with "0" (zero) to get fully unbuffered output)

simon3270
  • 712
  • 1
  • 5
  • 8