How to escape PowerShell double quotes from a .bat file

前端 未结 2 573
深忆病人
深忆病人 2020-12-19 23:23

I\'m trying to replace all double quotes in a file (temp1.txt) with two double quotes using this PowerShell command run from a bat file in Windows 7:

powersh         


        
2条回答
  •  萌比男神i
    2020-12-20 00:12

    The escape character is grave-accent for PowerShell. Try this instead:

    powershell -Command "(gc c:\temp\temp1.txt) -replace `", `"`" | Out-File -encoding UTF8 c:\temp\temp2.txt"
    

提交回复
热议问题