提取这个字符串的末尾端口号
2017-04-17 08:16:14 INFO connecting lh3.googleusercontent.com:443 from 111.111.111.111:26215
我可以用grep awk 做出来
1.grep echo "2017-04-17 08:16:14 INFO connecting lh3.googleusercontent.com:443 from 111.111.111.111:26215"| grep -Po 'd+$'
2.ack echo "2017-04-17 08:16:14 INFO connecting lh3.googleusercontent.com:443 from 111.111.111.111:26215"| ack -o 'd+$'
为何下面的sed awk 无法做到?
3.sed echo "2017-04-17 08:16:14 INFO connecting lh3.googleusercontent.com:443 from 111.111.111.111:26215"| sed 's/(.*)::(d+)$/2/g'
4.awk echo "2017-04-17 08:16:14 INFO connecting lh3.googleusercontent.com:443 from 111.111.111.111:26215"| awk '{b=gensub(/^(.+)d+)$/,"2","g";print b}'
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…