2

I have a netcat udp connection listening with nc -l -u .... I've been trying to do a per packet manipulation of the incoming data with just command line, but it doesn't look like there is a flag in netcat to indicate a new packet.

First, is it possible to just apply a new line to the end of each packet coming in from netcat?

If not, is there a way instead to match a string and output a new line while netcat is streaming in data?

  • You won't be able to distinguish a UDP packet that contains a newline from two separate UDP packets. Try if one of socat's plethora of options solves your problem, but you may need to move on to Perl/Python/Ruby. – Gilles Aug 13 '13 at 22:41
2

Server side:

# nc -l -u -p 666 > /tmp/666.txt

Other server side's shell:

# tail -F /tmp/666.txt | while IFS= read -r line; do
    echo "$line";
    # do what you want.
  done;

Client side:

# nc -uv 127.0.0.1 666

#### Print your commands.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.