2017-07-27 238 views
-1

我米试图查找和替换特定的标签这是继:SED搜索和替换HTML标记

<@include_page path='/FooServlet' params={'itemType': 'component', 'id': '92', 'componentURI': 'foo:92-20975', 'templateURI': 'ttt:92-1082-32','lazyLoad':'enabled' }/> 

I want to replace it with 

<#-- <@include_page path='/FooServlet' params={'itemType': 'component', 'id': '92', 'componentURI': 'foo:92-20975', 'templateURI': 'ttt:92-1082-32','lazyLoad':'enabled' }/> --> 

我能够与 find . -type f -exec sed -i '/20975/d' {} \;

但是要删除的行,我需要注释掉线条20975

同样,我将需要删除注释掉之后。

任何帮助表示赞赏。

+0

更新了问题。 – DarthVader

+0

'sed'/ 20975/s/^/<# - /'' –

+0

尝试'sed -i'/20975/s/.*/ <#-- & --> /'文件' – SLePort

回答

0
sed 's/.*20975.*/<#-- & -->/' file 
+2

我很惊讶,有点失望这种来自85k声望的人的答案。 – Pete

+0

@Pete你有GOT开玩笑。这是绝对基本的,完全基本的'sed'。如果你认为它需要任何一种解释性文字,你是完全错误的。 –

+2

@EdMorton如果它是绝对基本的,完全基本的'sed',那么这个问题不属于这里开始,不应该回答。 – Pete