美文网首页
三剑客取ip地址

三剑客取ip地址

作者: linux_龍 | 来源:发表于2019-10-12 17:20 被阅读0次
image.png image.png
[root@m01 ~]# hostname -I|awk '{print $1}'
10.0.0.61
[root@m01 ~]# hostname -I|cut -d " " -f1 
10.0.0.61
[root@m01 ~]# awk -F= '/IPADDR/{print $2}'  /etc/sysconfig/network-scripts/ifcfg-eth0  
10.0.0.61
[root@m01 ~]# sed -n '/IPADDR/s#^.*=##gp' /etc/sysconfig/network-scripts/ifcfg-eth0
10.0.0.61
[root@m01 ~]# ip a  s eth0 |awk -F'[ /]+' 'NR==3{print $3}'
10.0.0.61
[root@m01 ~]# ip a  s eth0 |awk -F'inet |/24' 'NR==3{print $2}'
10.0.0.61
[root@m01 ~]# ip a  s eth0 |awk -F'[^0-9.]+' 'NR==3{print $2}'
10.0.0.61
[root@m01 ~]# ip a s eth0 |sed -nr '3s#^.*et |/.*$##gp'
10.0.0.61
[root@m01 ~]# ip a s eth0 |sed -nr '3s#^.*et (.*)/.*$#\1#gp'
10.0.0.61

相关文章

网友评论

      本文标题:三剑客取ip地址

      本文链接:https://www.haomeiwen.com/subject/toflyctx.html