Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to convert a file from DOS to Unix [closed]

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
like image 221
judi Avatar asked Aug 18 '15 05:08

judi


1 Answers

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)
like image 102
Jower Avatar answered Sep 22 '22 15:09

Jower