WIndows and LF to CR/LF issues

Posted on 2014-08-21
Medium Priority
Last Modified: 2014-08-21
I have a file that apparently originated from Line, and I need to convert it to Windows format

What is the easiest way to do that

Question by:Anthony Lucia
LVL 13

Accepted Solution

Rizzle earned 2000 total points
ID: 40277145
Do you mean originated from Linux?

Also if its from Linux heres the solution.

If you’re using a UNIX based system to transfer the files to a Windows system, there are some commands that let you convert the text file(s) you are transferring to a format Windows can understand.

The dos2unix and unix2dos command


You can use command line to safely convert files from UNIX to Windows and vice versa. To convert a Windows text file to a UNIX text file, enter this:

dos2unix windows.txt unix.txt

The above command converts and replaces “windows.txt” file to “unix.txt”. To convert a UNIX text file to a Windows text file, enter this command:

unix2dos unix.txt windows.txt

The above command will convert a UNIX created text file called “unix.txt” to a Windows compatible text file called “windows.txt”.

The awk command

The awk command also lets you convert a file from UNIX to Windows and vice versa. To convert a Windows file to a UNIX file, enter the following command:

awk '{ sub("\r$", ""); print }' windows.txt > unix.txt

To convert a UNIX text file called “unix.txt” to a Windows text file called “windows.txt”, enter the following command:

awk 'sub("$", "\r")' uniz.txt > windows.txt

Author Comment

by:Anthony Lucia
ID: 40277158
I am on WIndows 2008 R2

Neither dos2unix or awk work in this env on the command prompt

Any ideas ?

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Know the reasons and solutions to move/import EDB to New Exchange Server. Also, find out how to recover an Exchange .edb file and to restore the file back.
The article covers five tools all IT professionals should know about, as they up productivity by a great deal!
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question