How to convert DOS line endings in Linux

1146765 pts.
Tags:
DOS
Linux
I'm using Linux. When I'm trying to open files that were created in Windows, all the lines keep ending with ^M. Is there a way to delete them all at once. Thank you.
1

Answer Wiki

Thanks. We'll let you know when a new response is added.
Hi,

I prefer to use the following command :

:set fileformat=unix

You can also use mac or dos to respectively convert your file to macintosh or MS-DOS/MS-Windows file convention. And it does nothing if the file is already in the correct format.

For more information, see the vim help : :help fileformat

Thanks & Regards
Clark Kent

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • Genderhayes
    Use does2unix converts text files
    10,720 pointsBadges:
    report
  • brydell

    There are two commands for just this purpose:

    dos2unix one_file
    unix2dos  another file
    The first one will convert a file from "DOS format", 
    i.e. it will remove all ^m from a text file.
    The second one will add them, making a unix-created file readble 
    by DOS programs.
     
    575 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: