删除的第一场比赛 [英] Delete first match

查看:79
本文介绍了删除的第一场比赛的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一种方法来删除某条线路的第一场比赛,而不是最后一个。
为了解释这个更好的,这里是我的文件:

I'm trying to find a way to delete the first match of a certain line, and not the last one. To explain this better, here is my file:

(Foo Bar)
Foo = B(ar)a(foo)r

我的问题是,我想删除(),并在它的文本。
这是我目前的code:

My problem is that I'm trying to delete the () and the text within it. Here is my current code:

sed 's:(.*)::g'

但这种输出:

Foo = Br

而不是这样的:

Foo = Bar

这将如何做?

推荐答案

* 是贪婪的,这将匹配到最后

* is greedy, and that will match till the last ).

sed 's:([^)]*)::g'

这篇关于删除的第一场比赛的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆