Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
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

1 Answer 1

up vote 2 down vote accepted

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.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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