I want to echo some text that contains double quotation marks in a text file using PowerShell:
powershell echo " > file.txt
But this fails, I did my searching, and it suggested to use the ` character to escape quotes, but this did not work.
I want to echo some text that contains double quotation marks in a text file using PowerShell:
powershell echo " > file.txt
But this fails, I did my searching, and it suggested to use the ` character to escape quotes, but this did not work.
You want to do do something like this as per the PowerShell quoting rules:
Use single quote to define your string:
echo '"' > file.txt
Or use double quotes to define your string and escape your character with the ` character:
echo "`"" > file.txt
You could also use the Set-Content PowerShell command to create the file as well:
'"' | Set-Content file.txt