How can I run dos2unix on an entire directory? [closed]
find . -type f -print0 | xargs -0 dos2unix Will recursively find all files inside current directory and call for these files dos2unix command
find . -type f -print0 | xargs -0 dos2unix Will recursively find all files inside current directory and call for these files dos2unix command
You can use Notepad++. The instructions to convert a directory recursively are as follows: Menu: Search -> Find in Files… Directory = the directory you want to be converted to Unix format, recursively. E.g., C:\MyDir Find what = \r\n Replace with = \n Search Mode = Extended Press “Replace in Files”
Some options: Using tr tr -d ‘\15\32’ < windows.txt > unix.txt OR tr -d ‘\r’ < windows.txt > unix.txt Using perl perl -p -e ‘s/\r$//’ < windows.txt > unix.txt Using sed sed ‘s/^M$//’ windows.txt > unix.txt OR sed ‘s/\r$//’ windows.txt > unix.txt To obtain ^M, you have to type CTRL-V and then CTRL-M.
The problem is that your input file uses DOS line endings of CRLF instead of UNIX line endings of just LF and you are running a UNIX tool on it so the CR remains part of the data being operated on by the UNIX tool. CR is commonly denoted by \r and can be seen … Read more
dos2unix is a commandline utility that will do this, or :%s/^M//g will if you use Ctrl–v Ctrl–m to input the ^M, or you can :set ff=unix and Vim will do it for you. There is documentation on the fileformat setting, and the Vim wiki has a comprehensive page on line ending conversions. Alternately, if you … Read more