使用 netcat 逐行发送文本文件 [英] Send text file, line by line, with netcat
本文介绍了使用 netcat 逐行发送文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用以下命令逐行发送文件:
I'm trying to send a file, line by line, with the following commands:
nc host port < textfile
cat textfile | nc host port
我尝试过 tail 和 head,但结果相同:整个文件作为唯一行发送.服务器正在侦听特定守护进程以接收数据日志信息.
I've tried with tail and head, but with the same result: the entire file is sent as a unique line. The server is listening with a specific daemon to receive data log information.
我想逐行发送和接收行,而不是一次性发送和接收整个文件.
I'd like to send and receive the lines one by one, not the whole file in a single shot.
我该怎么做?
推荐答案
你必须使用 netcat 吗?
Do you HAVE TO use netcat?
cat textfile > /dev/tcp/HOST/PORT
也可以达到您的目的,至少使用 bash.
can also serve your purpose, at least with bash.
我想逐行发送和接收行,而不是一次性发送和接收所有文件.
I'de like to send, and receive, one by one the lines, not all the file in a single shot.
试试
while read x; do echo "$x" | nc host port; done < textfile
这篇关于使用 netcat 逐行发送文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文