How do I pass a literal double quote from PowerShell to a native command?

后端 未结 3 1433
孤独总比滥情好
孤独总比滥情好 2020-12-17 21:04

I\'d like to print a string literal in AWK / gawk using the PowerShell command line (the specific program is unimportant). However, I think I misunderstand the quoting rules

3条回答
  •  渐次进展
    2020-12-17 21:35

    Quoting rules can get confusing when you're calling commands directly from PowerShell. Instead, I regularly recommend that people use the Start-Process cmdlet, along with its -ArgumentList parameter.

    Start-Process -Wait -FilePath awk.exe -ArgumentList 'BEING {print "Hello"}' -RedirectStandardOutput ('{0}\awk.log' -f $env:USERPROFILE);
    

    I don't have awk.exe (does that come from Cygwin?), but that line should work for you.

提交回复
热议问题