shell脚本探测主机存活

首先我有一些IP地址在文本中,我需要知道他们所在主机是否存活

[root@localhost shell]# cat ip.txt 

47.102.212.99

47.102.212.223

119.3.103.33

225.17.221.123


方法一:使用for循环

#!/bin/bash
###############################
##for循环ping文本中的IP
##
##############################
#设置变量
list=`cat $(pwd)/ip.txt`
#for循环遍历文本中的内容
for ip in $list
do
#ping一次,超时时间1秒 混合