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.
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.
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.
In vim, use :set ff=unix to convert to Unix; use :set ff=dos to convert to Windows.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With