WIndows and LF to CR/LF issues

Posted on 2014-08-21
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

    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
    I am on WIndows 2008 R2

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

    Any ideas ?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Are end users causing IT problems again?

    You’ve taken the time to design and update all your end user’s email signatures, only to find out they’re messing up the HTML, changing the font and ruining the imagery. What can you do to prevent this? Find out how you can save your signatures from end users today.

    New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
    The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
    The viewer will learn how to download, install and use CrashPlan from on Windows 7. Open your browser and go to Click get started, it’s free then Click the Download CrashPlan button: Click save in Internet Explorer, the…
    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.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now