[求助]如何提取文件中出现的ip:port[已解决]
发表于 : 2012-06-27 20:20
示例文件:
提取结果:
83.226.165.182:443
78.147.155.162:9001
86.204.237.150:443
网上搜索到的只能提取IP
如
提取结果少了一个
如
如何修改或者新的命令来提取出123.456.789.012:9001此种格式的结果
不懂sed和awk,请帮忙.
谢谢2楼的快速回复解决了我的难题.
代码: 全选
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head><body><p>Here are your bridge relays: <pre id="bridges">bridge 83.226.165.182:443
bridge 78.147.155.162:9001
bridge 86.204.237.150:443
</pre></p><ul><li>gmail.com</li><li>yahoo.com</li></ul><hr /><p>Note for experts: if you can use IPv6, try upgrading to 0.2.3.12-alpha and use this IPv6 address in your bridge line:<br /><tt>[2001:948:7:2::164]:6001</tt><br />Let us know how it goes!</p></body></html>
83.226.165.182:443
78.147.155.162:9001
86.204.237.150:443
网上搜索到的只能提取IP
如
代码: 全选
sed -n 's,^[^ ]*[ ]\([0-9][0-9]*\(\.[0-9][0-9]*\)\{3\}\):.*$,\1,p' test
如
代码: 全选
awk '{gsub(/[^0-9.]/," ",$0);for(i=1;i<=NF;i++) if($i~/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) print $i}' test
不懂sed和awk,请帮忙.
谢谢2楼的快速回复解决了我的难题.