Listen on a network port and save data to a text file

Martin Petercak picture Martin Petercak · Jan 20, 2012 · Viewed 80.6k times · Source

Is there some easy way in linux to listen for data on network and save them to a text file?

Thank you.

Answer

TomT the Weatherman picture TomT the Weatherman · Jan 20, 2012

Netcat is your friend here.

nc -l localhost 10000 > log.txt

Netcat will listen for a connection on port 10000, redirect anything received to log.txt.