awk 按多個字符進行切割


[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都是空字符串。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM