[root@centos7 ~]#ifconfig eth0 |grep -i mask|grep -oE '([0-9]{1,3}\.){3}[0-9]{1,3}' |head -1
10.0.0.7
[root@centos7 ~]#ifconfig eth0 |sed -nr '2s/.*inet ([0-9.]+) .*/\1/p'
10.0.0.7
[root@centos7 ~]#ifconfig eth0 |sed -n '2p' | awk '{print $2}'
10.0.0.7
[root@centos7 ~]#ifconfig eth0 | awk 'NR==2{print $2}'
10.0.0.7
取ifconfig 输出结果中的IP地址
最新推荐文章于 2023-06-29 17:18:28 发布