标签:shell
代码如下:
#ac=`ifconfig -a | grep encap | awk ‘{print $1}‘` ac=`ifconfig | grep encap | awk ‘{print $1}‘` for i in $ac do 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" done gw=`netstat -rn | grep "^0.0.0.0" | awk ‘{print $2}‘` echo "Default Gateway:"$gw
运行结果如下:
[root@localhost]# sh t.sh eth0 addr:10.12.1.134 Mask:255.255.255.224 Speed:1000Mb/s Duplex:Full lo addr:127.0.0.1 Mask:255.0.0.0 Default Gateway:10.12.1.129
标签:shell
原文地址:http://flyingzf.blog.51cto.com/38414/1767270