首页 > 系统服务 > 详细

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

时间:2016-01-26 16:42:17      阅读:161      评论:0      收藏:0      [点我收藏+]

#!/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

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

原文:http://www.cnblogs.com/lzy1991/p/5160782.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!