[root@xiaoyuan ~]# ip a s eth0 | grep inet
  inet 172.31.142.158/20 brd 172.31.143.255 scope global dynamic eth0

  inet 192.168.170.133/24 brd 192.168.170.255 scope global eth0:1
[root@xiaoyuan ~]# ip a s eth0 | grep inet | awk -F '/|[ ]' 'NR==1{print $6}'
172.31.142.158

注意:inet前面有4个空格,切割后$1~$4都是空字符串。

相关文章:

  • 2022-12-23
  • 2021-10-14
  • 2021-12-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
猜你喜欢
  • 2021-07-25
  • 2022-01-31
  • 2022-12-23
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2021-07-01
相关资源
相似解决方案