小编Jam*_*kay的帖子

Powershell - UNIX ANSI文件编码被更改并生成CRLF

我在Windows中使用Powershell在Unix中生成的文件中用'$'替换'£'.问题是输出文件在每行的末尾都有CRLF而不是它最初的LF.当我在Notepad ++中查看原始文件时,状态栏告诉我它是Unix ANSI,我想保留这种格式并在每行的末尾都有LF.我已经尝试了所有的编码选项没有成功,我也尝试过Set-Content而不是Out-File.我的代码是:

$old = '£'
$new = '$'
$encoding = 'UTF8'
(Get-Content $fileInfo.FullName) | % {$_ -replace $old, $new} | Out-File -filepath $fileInfo.FullName -Encoding $encoding
Run Code Online (Sandbox Code Playgroud)

谢谢Jamie的任何帮助

unix powershell encoding newline

2
推荐指数
1
解决办法
1380
查看次数

标签 统计

encoding ×1

newline ×1

powershell ×1

unix ×1