Laeeq
Laeeq

Reputation: 365

How to assign Awk output to netcat?

I want to transfer first field of a file. I am using awk to pull the first field and then send it using netcat. But I don't get anything on the otherside. I am using the following command

awk -F, '{print  $1}' sample.csv | netcat -lk 9999

Any hints would be much appreciated.

Regards, Laeeq

Upvotes: 1

Views: 353

Answers (1)

TinkerTank
TinkerTank

Reputation: 5815

I ran into this same problem when piping awk output to netcat. Turns out, awk buffers a lot.

Text can be flushed on each line with the fflush() command. The following works for me:

awk -F, '{print  $1} fflush()' sample.csv | netcat -lk 9999

Upvotes: 1

Related Questions