筛选IPV4地址

从ifconfig命令中的结果中筛选除了IO网卡的所有的IPV4地址。

执行ifconfig查看一下网卡

 

 执行     ifconfig |awk '/inet /'

 

 

 

 

 

 

 

ifconfig | awk '/inet / && !($2 ~ /^127/){print $2}'方法一

按段落读取的:RS按段落读取的

ifconfig |awk 'BEGIN{RS=""}!/Io/{print $6}'   方法二

ifconfig | awk 'BEGIN{RS="";FS="\n"}!/Io/{$0=$2;FS=" ";$0=$0;print $2}'   方法三

 

posted @ 2021-11-05 16:54  晨起的太阳  阅读(137)  评论(0编辑  收藏  举报