I need to convert a file from DOS to Unix in PowerShell.
I know this can be very much easily done in Unix:
dos2unix file newfile
It could be as simple as
Get-Content in.csv -raw | % {$_ -replace "`r", ""} | Set-Content -NoNewline out.csv
Above method will work on powershell version 3+. If you are below that you can use below method instead. Almost same as one of the other answers here.
$csvdata = [io.file]::ReadAllText('in.csv') | % {$_ -replace "`r",""}
[io.file]::WriteAllLines('out.csv', $csvdata)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With