I have some shell scripts created on windows I want to run dos2unix
on them.
But as I have read that dos2unix
works in Linux
You can use Notepad++.
The instructions to convert a directory recursively are as follows:
\r\n
\n
If you have perl
installed, you can simply run:
perl -i -p -e "s/\r//" <filename> [<filename2> ...]
I used grepWin:
\r\n
\n
Solved it trough Notepad++.
Go to: Edit -> EOL Conversion -> Unix.
In PowerShell there are so many solutions, given a lot of tools in the .NET platform
With a path to file in $file = 'path\to\file'
we can use
[IO.File]::WriteAllText($file, $([IO.File]::ReadAllText($file) -replace "`r`n", "`n"))
or
(Get-Content $file -Raw).Replace("`r`n","`n") | Set-Content $file -Force
To do that for all files just pipe the file list to the above commands:
Get-ChildItem -File -Recurse | % { (Get-Content -Raw `
-Path $_.Fullname).Replace ("`r`n", "`n") | Set-Content -Path $_.Fullname }
See
For bigger files you may want to use the buffering solutions in Replace CRLF using powershell
You are using a very old dos2unix version on Cygwin. Cygwin 1.7 changed to a new version of dos2unix, the same as is shipped with most Linux distributions, about two years ago. So update your dos2unix with Cygwin's setup program. Check you get version 6.0.3.
There are also native Windows ports of dos2unix available (win32 and win64). See http://waterlan.home.xs4all.nl/dos2unix.html
regards,