file transfer with nc command on Linux

1、先在receiver上使用nc监听端口(6543),并将接收的内容都重定向到文件里(out.file)

nc -lvp 6543 > out.file

2、在sender上将文件发送至receiver机器的端口上

nc -q 1 ip 6543 < in.file

为了能够自动退出,增加里-q选项

-q seconds   after EOF on stdin, wait the specified number of seconds
             and then quit. If seconds is negative, wait forever.

Disclaimer
  1. License under CC BY-NC 4.0
  2. Copyright issue feedback: dig +short txt issue.imzye.com
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Buy Me a Coffee