参考

ip a|grep -o -E "([0-9]{1,3}\\.){3}[0-9]{1,3}" 

grep 正则适用任何文档匹配抽取

grep 正则取IP和端口号

netstat -tunlpa |grep -o -E "([0-9]{1,3}\\.){3}[0-9]{1,3}.?[0-9]{1,5}

借鉴文章:
https://blog.csdn.net/weixin_34032779/article/details/92242868?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1.pc_relevant_paycolumn_v3&utm_relevant_index=2

Logo

更多推荐