Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 linux 中编写一个 bash 脚本来获取多个 IP 地址并用于socat侦听端口 5000,如果收到一条消息,则将其发送到所有 IP 地址。
socat
我怎样才能做到这一点??
您可以为此使用 for 循环。假设您在名为 ipaddresses.txt 的文件中有一个 IP 地址列表
for ips in `cat ipaddresses.txt` ; do dowhatever done
或者你可以做这样的事情。
for ips in `ifconfig | grep 'inet addr' | awk -F ":" '{print $2}' | awk '{print $1}'` ; do dowhatever done