i=1
for
lines
in
`cat
tt.txt`
do
case
${i}
in
1)
var1=${lines}
2)
var2=${lines}
3)
var3=${lines}
4)
var4=${lines}
5)
var5=${lines}
6)
var6=${lines}
esac
i=`expr
${i}
+
1`
done
echo
${var1}
echo
${var2}
echo
${var3}
echo
${var4}
echo
${var5}
echo
${var6}
#!/bin/bashNR=$(wc -l ./hosttable.txt|cut -d " " -f 1 )
i=1
while [ $i -le $NR ]
do
ip=$(head -$i ./hosttable.txt|tail -1|cut -d " " -f 1)
name=$(head -$i ./hosttable.txt|tail -1|cut -d " " -f 2)
ping -c 1 $ip >/dev/null
if [ $? -ne 0 ] then
echo "Destination Host Unreachable.(name:$name,IP:$ip)"
fi
i=$(( $i + 1 ))
done
把上面的脚本和hosttable.txt放在同一目录下执行,hosttable.txt中ip和主机名用一个空格来间隔
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)