[root@15b883 ~]# ifconfig eth0 |sed -nr '/inet addr/s#[^0-9]*([0-9.]*).*#\1#gp'
192.168.31.128
[root@15b883 ~]# ifconfig eth0 |sed -n '2p'|sed 's#^.*dr:##g'|sed's# B.*$##g'
192.168.31.128
[root@15b883 ~]# ifconfig eth0 |sed -n '2s#^.*dr:##gp' |sed 's# B.*$##g'
192.168.31.128
[root@15b883 ~]# ifconfig eth0 |sed -nr 's#^.*dr:(.*) B.*$#\1#gp'
192.168.31.128
[root@15b883 ~]# ifconfig eth0 |awk -F "[ :]+" 'NR==2{print $4}'
192.168.31.128
[root@15b883 ~]# ifconfig eth0 |grep -o "inetaddr:[0-9.]*"|grep -o "[0-9.]*"
192.168.31.128
[root@15b883 ~]# ifconfig eth0|sed -n '2p' |sed -r's#(^.*dr:)(.*)( Bc.*$)#\2#g'
192.168.31.128
[root@15b883 ~]# ifconfig eth0 |grep -Po '(?<=addr:)\S+'
192.168.31.128
[root@15b883]# hostname -i
211.98.71.195
[root@15b883]# hostname -I
10.0.0.100 172.16.1.100
本文出自 “宋某人c” 博客,请务必保留此出处http://syaving.blog.51cto.com/5614476/1856532