centos6和7通用
[root@centos6 ~]#ifconfig |sed -n '2p'|sed -r 's/^[^0-9]+([0-9.]+).*/\1/'
192.168.36.61
[root@centos7 ~]#ifconfig |sed -n '2p'|sed -r 's/^[^0-9]+([0-9.]+).*/\1/'
192.168.36.71
或者
[root@centos6 ~]#ifconfig |sed -nr '2s/^[^0-9]+([0-9.]+).*/\1/p'
192.168.36.61
[root@centos7 ~]#ifconfig |sed -nr '2s/^[^0-9]+([0-9.]+).*/\1/p'
192.168.36.71