大佬教程收集整理的这篇文章主要介绍了awk – 删除匹配字符后的所有字符,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
http://example.com/part-1 this number 1 one http://example.com/part--2 this is number 21 two http://example.com/part10 this is an number 12 ten http://example.com/part-num-11 this is an axample number 212 eleven
如何删除第一个列和“数字x”之间的“数字x”之后的所有字符…我想要这样的输出
http://example.com/part-1 1 http://example.com/part--2 21 http://example.com/part10 12 http://example.com/part-num-11 212
另一个案例:
输入:
http://server1.example.com/00/part-1 this number 1 one http://server2.example.com/1a/part--2 this is section 21 two two http://server3.example.com/2014/5/part10 this is an Part 12 ten ten ten http://server5.example.com/2014/7/part-num-11 this is an PARt number 212 eleven
sed -r 's/^([^0-9]*[0-9]+)[^0-9]*([0-9]+).*/\1 \2/' file
输出:
http://example.com/part-1 1 http://example.com/part--2 21 http://example.com/part10 12 http://example.com/part-num-11 212
以上是大佬教程为你收集整理的awk – 删除匹配字符后的所有字符全部内容,希望文章能够帮你解决awk – 删除匹配字符后的所有字符所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。