[System.IO.File]::writeAllines在末尾添加换行符
我有以下代码:[System.IO.File]::writeAllines在末尾添加换行符,file,shell,powershell,newline,File,Shell,Powershell,Newline,我有以下代码: # 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 ...
# 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
之外,我还能做些什么吗?我不会说Powershell,但在我看来,你已经告诉它在结尾处用换行符(CRLF)写一大行($bash\u script
)。打电话吧。确保在文件末尾有一个LF
$bashScript = "#!/bin/bash`n" + [string]::Join("`n", $cmds) + "`n"
[System.IO.File]::WriteAllText($location.ToString() + ".\build.sh", $bashScript);
我不会说Powershell,但在我看来,你已经告诉它写一行大的(
$bash_script
),结尾有一个换行符(CRLF)。打电话吧。确保在文件末尾有一个LF
$bashScript = "#!/bin/bash`n" + [string]::Join("`n", $cmds) + "`n"
[System.IO.File]::WriteAllText($location.ToString() + ".\build.sh", $bashScript);