Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
[System.IO.File]::writeAllines在末尾添加换行符_File_Shell_Powershell_Newline - Fatal编程技术网

[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);