Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I recently moved back to Windows from Linux. I have some files with CRLFs, some with LFs and some that are mixed. Is there a utility that will help me find all my Unix-touched files and convert them to proper CRLF terminated files?

EDIT: The utility must run on Windows, not Linux. I have already moved. I'd rather not install Cygwin if I can avoid it.

share|improve this question
related: see superuser.com/questions/38744 superuser.com/questions/27060 superuser.com/questions/52044 ... any tool mentioned in those can be reversed to accomplish what you want to do –  quack quixote Nov 17 '09 at 4:59
Duplicate question –  ukanth Nov 17 '09 at 9:40
The solutions in those so called Duplicate questions all run on linux platforms or preform the opposite conversion. I don't have linux any more. I have windows. –  Matthew Scouten Nov 17 '09 at 14:50
they are all available for Windows via Cygwin, GnuWin32, UnxUtils or the like. i believe there are Powershell scripts that can do this as well, though i don't know enough about it to provide any links. –  quack quixote Nov 17 '09 at 15:00
@quack: The question specifically states that the user is looking for something that will do the job on Windows, using a Windows utility. –  Brian Lacy Nov 19 '10 at 21:00

11 Answers 11

up vote 17 down vote accepted

You can convert them with the unix2dos utility on your Linux platform. There are unix2dos versions available for Windows as well.

If you have Perl installed you can also use this one liner:

perl -p -e 's/\n/\r\n/' < UNIX_LF.txt > WINDOWS_CRLF.txt
share|improve this answer
I did something similar to this, but I used python. –  Matthew Scouten Nov 19 '09 at 2:27
@Matthew Scouten: so... you found a unix utility that runs on windows! congrats! –  quack quixote Nov 19 '09 at 13:31
yes and no. I WROTE my own blasted utility. I could have done this from the start, but I was hoping to save 30 mins. Unfortunately I was not happy with any utilities available. The closest I found corrupted any binary files in the directory. –  Matthew Scouten Nov 20 '09 at 15:08

Here is an easy and quick way.

Drag and drop the text file into chrome (idk about other browsers) and then cut & paste back into the original file :)

share|improve this answer
+1, I like quick hacks ;) –  UpTheCreek Nov 9 '12 at 8:40
This is really cool, I tried with Firefox and it works. –  Praveen Sripati Nov 23 '14 at 13:51

I know this thread is old but it still comes up in searches for solutions. The one I found best for recursively going through folders, allowing file filters and allowing a simple search for "\r\n" and replacing it with just "\n" was Notepad++

Notepad++ is one of the best, free, open source notepad programs for Windows. It is very simple and powerful. It handled the line ending search/replace just fine. A contractor check a bunch of .c and .h files in to our repository with Linux \r\n line endings but since most people have standardized on Windows/Eclipse build tools, the files won't build until the line endings are converted.

share|improve this answer
I think you reversed the endings there: linux is \n, windows is \r\n –  Matthew Scouten Apr 8 '11 at 7:12
Notepad++ also has a simple Edit -> EOL Conversion menu if the number of files to convert is small. –  user1071136 Jul 24 '12 at 22:21

Use the Swiss File Knife.

For example: sfk addcr -dir . -file .txt -norec
changes LF endings into CR/LF for Windows, on all .txt files of the current directory, but NOT within subdirectories (no recursion).

But this program does a lot more than just that.

share|improve this answer

On Cygwin, you can convert between Unix and "DOS" AKA Windows files using two built-in utilities:

Convert to DOS CR/LF format:

u2d filename

Convert back to Unix CR format:

d2u filename

The file is left in place with the same name.

Enjoy! Rick

share|improve this answer

Use a text editor that understands both line endings like scite, or notepad++, If you don't need to convert all line ending in all your files, but just don't want to see the entire file bunched up on the first line.

share|improve this answer
That's what they said when I had the inverse problem while switching to linux. I kept running into tools that had problems with the wrong line endings. And NOTHING handles mixed line endings reasonably. –  Matthew Scouten Mar 31 '11 at 17:05
@Matthew I know the scite handle unix / windows line endings correctly. I use it for that purpose in the windows vms I run in linux when editing files on the host system. –  nelaar Apr 1 '11 at 10:54
I am sure that the editors you recommend will work just fine. but at some point, I will need to feed the textfile to some other tool, and that tool will NOT. At that point, having a text editor that handles things well will make it worse by hiding the problem. and I will bet that it still handles mixed endings badly (or at least with quirks). –  Matthew Scouten Apr 1 '11 at 13:44
+1 for the notepad++ option to convert lie endings. And here is how to do more specifically (see "method 2") : staffwww.fullcoll.edu/brippe/csci123/saveAsUnix.aspx –  wil May 30 '12 at 1:34

My Linux distribution has two little utilities called fromdos and todos that I use for this task.

share|improve this answer

There are many ways to translate the eoln characters in TEXT files, and everyone has a favourite.

But I always transfer files from Linux to Windows in BINARY mode, then I open TEXT files in Windows with an editor capable of opening both types, and saving them in either form, if necessary.

I used Programmers File Editor for this, but Notepad++ can do it too. WordPad is also useful [at least, for viewing LF terminated files].

I'm thinking of the simple text files which may have originated on Linux, and need to be readable in the (defacto standard) world of Windows. I'm not sure what you meant by 'unix-touched files'.

share|improve this answer
The problem with this method is that it only does one file at a time. –  Matthew Scouten Nov 19 '09 at 2:23
'unix-touched files' is my word for both LF-only and mixed CRLF-LF files. Once a file has been edited in unix-oid tools, it tends to get 'infected' with LF-only lines. –  Matthew Scouten Nov 19 '09 at 2:26
What I was really saying was that by choosing the right software for viewing text files, they don't have to be converted at all. BTW, I avoided taking you to task for describing CRLF terminated files as 'proper'. It depends entirely on your viewpoint. Each method is proper in its own OS. When a file is moved to a different OS, then we find that Win/Mac/Linux are all different. I suspect that the Unix/Linux method is the original one. –  pavium Nov 19 '09 at 2:38
You suspect wrong. ASCII standard was originally developed for teletype machines, and mandated CRLF. Most internet protocols (including HTTP, SMTP, FTP, IRC and many others) also require CRLF endings (most implementations accept bare LF for compatibility with non-compliant Unix programs). In this case, Windows is following the standard and Unix and Mac are breaking it. –  Matthew Scouten Jul 16 '10 at 4:06

I used to open the file in 'edit' and save as that the job was done ...

share|improve this answer

I open the file in my favourite text editor and use an Autohotkey script that maps Shift+Alt+L to do exactly this:

Send ^a
Send ^x
Send ^v
share|improve this answer

To offer more options (even though I best enjoyed user45832's hack answer):

Online convertors

I guess a GUI FTP program will do it automatically

Batch/DOS one-liner (removes empty lines):

FOR /F "eol= delims= usebackq" %a IN (infile.txt) DO (ECHO %a>> outfile.txt)


gc infile.txt | %{$_.split("`n")} | Out-File outfile.txt

Got the last two from here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.