Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows command to convert Unix line endings?

Is there a Windows command to convert line endings of a file?

We have a test.bat which we need to run to start our server. We use Perforce and we need to have unix line endings in our workspace. For some reason, we are not allowed to change line endings to Windows in our workspaces. However, the server runs on Windows.

Everytime I have to run the bat file, I open it in Notepad++ and choose Edit→EOL conversion→Windows. Is there a way to automate this so that we won't need to manually change the line endings everytime we sync with Perforce?

Thanks in advance.

like image 773
Deepti Jain Avatar asked Jul 10 '13 19:07

Deepti Jain


People also ask

How do I change Unix line endings in Windows?

Converting using Notepad++ To write your file in this way, while you have the file open, go to the Edit menu, select the "EOL Conversion" submenu, and from the options that come up select "UNIX/OSX Format". The next time you save the file, its line endings will, all going well, be saved with UNIX-style line endings.

Can Windows handle Unix line endings?

So happy for you, Microsoft, \r\n Windows Notepad users, rejoice! Microsoft's text editing app, which has been shipping with Windows since version 1.0 in 1985, has finally been taught how to handle line endings in text files created on Linux, Unix, Mac OS, and macOS devices.

How do I change Unix format on PC?

In vim, use :set ff=unix to convert to Unix; use :set ff=dos to convert to Windows.

How convert LF to CRLF in Unix?

Answer. 2) On Windows or UNIX, gzip and gunzip has a -a switch that tells Windows gunzip to uncompress a file and change all LF's to CRLF. 3) If this is a PGP file, UNIX and Linux has several different utilities that change "UNIX" text files to "Windows" text files.


1 Answers

This can actually be done very easily using the more command which is included in Windows NT and later. To convert input_filename which contains UNIX EOL (End Of Line) \n to output_filename which contains Windows EOL \r\n, just do this:

TYPE input_filename | MORE /P > output_filename 

The more command has additional formatting options that you may not be aware of. Run more/? to learn what else more can do.

like image 130
TampaHaze Avatar answered Sep 27 '22 22:09

TampaHaze