CentOS 通过shell脚本过滤得到服务器IP地址


1.CentOS 6.x (32Bit &&64Bit)

[root@localhost ~]# ifconfig |grep Bcast |awk '{print$2}' |sed 's/addr://g'
192.168.31.46

 

2.CentOS 7.x (32Bit &&64Bit)

[root@jenkins ~]# ip addr show ens33 |grep -w inet |awk '{print $2}' |awk -F '/' '{print $1}'
192.168.31.43
或者
[root@jenkins ~]# ip a show dev ens33|grep -w inet|awk '{print $2}'|sed 's/\/.*//'
192.168.31.43

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM