开发者

How to find line number containing a string and replace the whole line with another string?

For ex.

If i have a line in a txt document "text.txt".Now what i want to do is open the file and read the contents.

When it find this "search.selectedEngine" term then it should delete that particular line and replace it with another string ("REPLACED STRING").

And then save the t开发者_如何学Goext document.

It would be great if you could give me the source for this.


sed -E 's/.*search\.selectedEngine.*/REPLACED STRING/g' /PATH/TO/FILE >/PATH/TO/NEW/FILE

This is case sensitive.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜