用引号和斜杠替换字符串

时间:2019-10-03 20:44:51

标签: powershell-3.0

我在文件中有以下字符串:

application=\"MyApp\"

,我想用PowerShell命令将其删除(或替换为”。

我尝试了一下,但是没用:

powershell -Command "Get-ChildItem -Path ./Transform\*.json -recurse | ForEach {If (Get-Content $_.FullName | Select-String -Pattern ' where useraction.application=\\\"MyApp\\\"') {(Get-Content $_ | ForEach {$_ -replace ' where useraction.application=\\\"MyApp\\\"', ' '}) | Set-Content $_ -encoding UTF8}}"

我认为在每个特殊字符前面加一个反斜杠是可行的,但到目前为止没有运气。

0 个答案:

没有答案