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都是空字符串。
posted on 2020-04-24 23:54 __director 阅读(975) 评论(0) 编辑 收藏 举报