简体   繁体   English

在Windows命令提示符中转义双引号

[英]Escaping double-quotes in the windows command prompt

I have a file with the following contents 我有一个包含以下内容的文件

$(CP) "$(O_SSL)" "$(INSTALLTOP)\bin"
$(CP) "$(O_CRYPTO)" "$(INSTALLTOP)\bin"

I want to add the following lines (order doesn't matter) 我想添加以下几行(顺序无关紧要)

$(CP) "$(SSL).pdb" "$(INSTALLTOP)\bin"
$(CP) "$(CRYPTO).pdb" "$(INSTALLTOP)\bin"

So, using perl, I created the following command (which must be run from the command prompt): 因此,使用perl,我创建了以下命令(必须在命令提示符下运行):

perl -pi.bak -e 's#\t\$\(CP\) "\$\(O_([^)]+)\)" "\$\(INSTALLTOP\)\\bin"#$&\n\t\$(CP) "\$($1).pdb" "\$(INSTALLTOP)\\bin#g' ntdll.mak

But I just get the following error 但我得到以下错误

Can't find string terminator "'" anywhere before EOF at -e line 1.
The system cannot find the path specified.

I tried replacing the single quotes with double quotes (and doubling all internal doublequotes) as so 我试过用双引号替换单引号(并使所有内部双引号加倍)

perl -pi.bak -e "s#\t\$\(CP\) ""\$\(O_([^)]+)\)"" ""\$\(INSTALLTOP\)\\bin""#$&\n\t\$(CP) ""\$($1).pdb"" ""\$(INSTALLTOP)\\bin""#g" ntdll.mak

but I just get the following error instead 但我只是得到以下错误

Substitution pattern not terminated at -e line 1.

How should I do this? 我应该怎么做? (... I don't want to create a separate script file, but I'll do it if there's no other (reasonable) way) (...我不想创建一个单独的脚本文件,但是如果没有其他(合理的)方法,我会做的)

我通过对文字双引号使用八进制转义来解决此问题

perl -pi.bak -e "s#\t\$\(CP\) \042\$\(O_([^)]+)\)\042 \042\$\(INSTALLTOP\)\\bin\042#$&\n\t\$(CP) \042\$(LIB_D)\\\$($1).pdb\042 \042\$(INSTALLTOP)\\bin\042#g" ntdll.mak

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

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