shell脚本 列出所有网卡的ip地址

#!/bin/bash
for i in `ifconfig | grep -o ^[a-z0-9]*`
do
ifconfig $i|sed -n 2p|awk '{ print $2 }'|tr -d 'addr:'
done

执行结果按行显示所有网卡的ip

 

ifconfig | grep -o ^[a-z0-9]* 命令列出所有的网卡接口

ifconfig $i|sed -n 2p|awk '{ print $2 }'|tr -d 'addr:'  命令 列出ip

posted @ 2016-01-26 16:17  伊小白  阅读(1092)  评论(0编辑  收藏  举报