代码如下:
#ac=`ifconfig -a | grep encap | awk '{print $1}'`ac=`ifconfig | grep encap | awk '{print $1}'`for i in $acdo if [ $i == "lo" ];then echo $i ifconfig $i | grep "inet addr" | sed 's/ //g' | awk '{print $2}END{print $3}' else echo $i ad=`ethtool $i | sed 's/\t//g' | grep 'Speed\|Duplex'` ifconfig $i | grep "inet addr" | sed 's/ //g' | awk '{print $2}END{print $4}' echo $ad | awk '{print $1 $2}END{print $3 $4}' fi echo -e "\r"donegw=`netstat -rn | grep "^0.0.0.0" | awk '{print $2}'`echo "Default Gateway:"$gw
运行结果如下:
[root@localhost]# sh t.sheth0addr:10.12.1.134Mask:255.255.255.224Speed:1000Mb/sDuplex:Fullloaddr:127.0.0.1Mask:255.0.0.0Default Gateway:10.12.1.129