\x0D
or \r
. \x0A
or \n
. dos2unix
changes DOS line endings in a file to UNIX endings. [IO.File]::WriteAllText( "$pwd\file.unix", [IO.File]::ReadAllText("$pwd\file.dos") -replace ("`r`n", "`n") )
$txt_mixed = "@$([char]0x0a)@$([char]0x0d)$([char]0x0a)@" $txt_dos = $txt_mixed -replace "(?<!`r)`n", "`r`n" # verify result: $text_dos | format-hex … … 40 0D 0A 40 0D 0A 40
show-newline.pl
is a Perl script that shows line endings in a file. dos-or-unix.pl
is another Perl script that tries to determine if a file has DOS or Unix line endings. System.Environment.NewLine
. chomp()
removes trailing new lines in variables that contain lines of text. str.splitlines()
. vbCrLf
. git config --global core.autocrlf false
wc
.