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
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
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.
Try this:
I used
WriteAllText
rather thanSet-Content
becauseSet-Content
adds a carriage return and a line feed to the end of the file, and there doesn't seem to be any way to suppress that.I think that the
-Raw
parameter toGet-Content
might be a PowerShell 3 thing, so if you are using an earlier version, you might need to do it like this: