开发者

how to remove `<h2 class='title'>Some text</h2>` using sed?

开发者 https://www.devze.com 2023-01-26 19:48 出处:网络
to remove text1, I simply use: find mydirectory -type f -exec sed -i \'s/text1//ig\' {} + but how to remove <h2 class=\'title\'>Some text</开发者_开发百科h2>?

to remove text1, I simply use:

find mydirectory -type f -exec sed -i 's/text1//ig' {} +

but how to remove <h2 class='title'>Some text</开发者_开发百科h2>?

I cannot simply remove using below code. it not works:

find mydirectory -type f -exec sed -i 's/<h2 class='title'>Some text</h2>//ig' {} +


You would need to escape the special characters

find mydirectory -type f -exec sed -i 's/<h2 class=\'title\'>Some text<\/h2>//ig' {} +
0

精彩评论

暂无评论...
验证码 换一张
取 消