我有一个带有 IP 地址的config.txt文件,内容如下
10.10.10.1:80
10.10.10.13:8080
10.10.10.11:443
10.10.10.12:80
我想ping该文件中的每个IP地址
#!/bin/bash
file=config.txt
for line in `cat $file`
do
##this line is not correct, should strip :port and store to ip var
ip=$line|cut -d\: -f1
ping $ip
done
我是初学者,很抱歉这样的问题,但我自己找不到。