sed/grep提取IP地址

来源:互联网 发布:奥比岛刷奥币软件 编辑:程序博客网 时间:2024/06/05 14:14
#利用grep查看ip a |grep inet[^6]|grep -E -o '([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]{1,2}'#利用sed查看ip a |grep inet[^6]|sed -r 's#inet (.*)/[0-9].*#\1#'

注:
[^6] 排除型字符组
. 匹配单一字符
* 前位字符出现0次或多次

原创粉丝点击