取IP的几个方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了取IP的几个方法相关的知识,希望对你有一定的参考价值。

ifconfig eth0|grep " inet add"|cut -d":" -f2|cut -d " " -f1

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

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

ifconfig eth0|sed -n ‘/inet addr/p‘|sed ‘s#.*addr:##g‘|sed  ‘s#  Bc.*$##g‘

ifconfig eth0|sed -n ‘s#^.*addr:\(.*\)  Bca.*$#\1#gp‘

 

以上是关于取IP的几个方法的主要内容,如果未能解决你的问题,请参考以下文章