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