简体   繁体   English

sed命令删除其中包含特殊字符的起始模式匹配

[英]sed command to delete starting pattern match with special character in it

I have sed command that delete line when string match with starting pattern 我有sed命令,当字符串与起始模式匹配时删除行

sed -i "/^Data\\=C\\b/Id" tally.ini

This work correctly for patch Data=C 对于补丁Data = C可以正常工作

But I want to match path Data=C:\\ and that I want to delete this line. 但是我想匹配路径Data = C:\\,并且我想删除这一行。

How can this possible? 这怎么可能呢?

sed -i  '/^Data\=C:\\/Id' tally.ini

Put the command in a single quoted string instead of double. 将命令放在单引号字符串中,而不是双引号中。 Escape the backslash. 转义反斜杠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM