取IPV4地址

https://www.cnblogs.com/gaara0305/p/10027343.html

ifconfig|grep -E 'inet\>'|awk '!/127.0.0.1/{print $2}'

ifconfig|grep -E 'inet\b'|awk '!/127.0.0.1/{print $2}'

ifconfig|grep -E 'inet\>'|awk '{print $2}'|grep -v '127.0.0.1'

ifconfig|grep -E 'inet\>'|awk '{print $2}'|grep -vE '^127.'

---------------------------------------------------------------------------------

 

[root@localhost temp]# cat 111
inet 192.168.2.136 netmask 255.255.255.0 broadcast 192.168.2.255
inet 127.0.0.2 netmask 255.0.0.0
inet 127.0.0.3 netmask 255.0.0.0
[root@localhost temp]# cat 111|awk '!/(127.0.0.2|127.0.0.3)/{print $2}'
192.168.2.136

 

posted @ 2022-09-02 16:39  shenshu  阅读(26)  评论(0编辑  收藏  举报