首页 > 其他 > 详细

如何取eth0中的IP地址

时间:2017-08-18 21:22:17      阅读:274      评论:0      收藏:0      [点我收藏+]

以下十多种方法,明白四种即可;

ifconfig eth0 |sed -n ‘2p‘ |sed‘s#^.*addr:##g‘|sed ‘s#  B.*$##g‘

ifconfig|awk -F "[: ]+"‘NR==2{print $4}‘

ifconfig |awk NR==2|sed -r‘s#^.*r:(.*)B.*#\1#g‘

ifconfig |sed -rn ‘2s#^.*r:(.*)B.*#\1#gp‘

ifconfig eth0|grep "inet a"|sed -r ‘s#^.*r:(.*)B.*#\1#g‘

ifconfig eth0|sed -rn ‘/inet a/s#^.*r:(.*)B.*#\1#gp‘

ifconfig eth0|grep ‘inetaddr‘|cut -d ":" -f2|cut -d " " -f1

ifconfig eth0|grep ‘inet addr‘|awk -F ":" ‘{print $2}‘|awk ‘{print $1}‘

ifconfig eth0|grep ‘inet addr‘|awk -F ‘[ :]‘ ‘{print $13}‘

ifconfig eth0|sed -n ‘2p‘|awk-F ‘[ :]+‘ ‘{print $4}‘

ifconfig eth0 |awk -F‘[ :]+‘ ‘NR==2 {print $4}‘

ifconfig eth0 |sed -nr ‘2s#^.*dr:(.*)  B.*$#\1#gp

ifconfig eth0|grep -Po ‘(?<=dr:)[0-9.]+‘

ifconfig eth0|sed -nr ‘2s#^.*addr:(.*) Bca.*$#\1#g‘p

ifconfig eth0|sed -n ‘2p‘|sed ‘s#^.*addr:\(.*\)Bc.*$#\1#g‘

hostname -l

如何取eth0中的IP地址

原文:http://dalongge.blog.51cto.com/13121286/1957448

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