我有这样的代码:
# Generate bash script
$bashScript = "#!/bin/bash`n";
$bashScript += [string]::Join("`n", $cmds)
[System.IO.File]::WriteAllLines($location.ToString() + ".\build.sh", $bashScript);问题是我总是在文件的末尾得到CRLF字符!
#!/bin/bash [LF]
tsc ... [LF]
java ... [LF]
java ... [CR][LF]除了最后替换CRLF之外,我还能做什么呢?
发布于 2012-10-30 17:53:16
我不会说Powershell,但在我看来,您告诉它要在末尾写一大行($bash_script)和换行符(CRLF)。改为调用WriteAllText。确保在文件的末尾有一个LF。
$bashScript = "#!/bin/bash`n" + [string]::Join("`n", $cmds) + "`n"
[System.IO.File]::WriteAllText($location.ToString() + ".\build.sh", $bashScript);https://stackoverflow.com/questions/13135808
复制相似问题