您的位置:首页 > 运维架构 > Shell

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

2016-01-26 16:17 776 查看
#!/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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: