如何在Power
shell中创建unix文件格式?我使用以下内容创建一个文件,但它总是以
Windows格式创建它.
"hello world" | out-file -filepath test.txt -append
据我所知,新行字符CRLF使其成为Windows格式文件,而unix格式只需要行末尾的LF.我尝试用以下内容替换CRLF,但它没有用
"hello world" | %{ $_.Replace("`r`n","`n") } | out-file -filepath test.txt -append
一个丑陋的答案是(从dos.txt输出到unix.txt的输入):
[string]::Join( "`n",(gc dos.txt)) | sc unix.txt
但我真的希望能够使Set-Content自己做这个,这个解决方案不会流,因此不适用于大文件……
而这个解决方案将以DOS行结束文件结束…所以它不是100%