Find the answer to your Linux question:
Results 1 to 5 of 5
Hi all, I have problem with text file formats. When my files are saved by Windows programs like Winword or other code editor like Visual Studio , they are added ...
  1. #1
    Just Joined!
    Join Date
    Nov 2004
    Posts
    47

    How can I get right text format?

    Hi all,

    I have problem with text file formats.

    When my files are saved by Windows programs like Winword or other code editor like Visual Studio , they are added some code for each line which display as ^M when opening by mc program in Linux (I am sorry, I just have very few idea about file format, so I don't know how to call it but to describe the phenomenon only ).

    Along time ago, I have ever used a code editor in which I can choose the file format to save so that no ^M display in mc. Now I can't recall what that program and what save option were.

    Could someone tell me what text editor I can use to change my file (with ^M showed in mc) into the wanted format (no ^M showed in mc) and which save option I have to use to save the file?

    Thanks a lot.

  2. #2
    Linux User eugrus's Avatar
    Join Date
    Dec 2004
    Location
    Russia
    Posts
    391
    Windows uses <cr><lf> for linebreak
    Old Macs use <cr> for linebreak.
    In UNIX <lf> character is used.

    So ^M is <cr> character

    To see no "^M" you'll have to use editors with Windows-type linebreak, such as kedit
    Russian UNIX Forums
    http://eugrus.pp.ru

  3. #3
    Linux Newbie
    Join Date
    Apr 2005
    Location
    Charlottesville, VA
    Posts
    175
    If indeed that is the problem, you could also try using unix2dos and dos2unix to convert between the two types.
    ---sxeraverx---
    Linux without a C Compiler is like eating Spaghetti with your mouth sewn shut. It just doesn't make sense.

  4. #4
    Linux User eugrus's Avatar
    Join Date
    Dec 2004
    Location
    Russia
    Posts
    391
    By the way GNU nano has options --dos and --mac which let you to use <cr><lf> or <cr> instead of <lf> character for linebreak
    Russian UNIX Forums
    http://eugrus.pp.ru

  5. #5
    Just Joined!
    Join Date
    Nov 2004
    Posts
    47
    Thanks for your help.
    dos2unix works for me. Also thanks for explanation about the CR and LF line terminators, it remind me about the day I wrote my first programs on PC, I already met the line terminators ascii number 10 and 13. How can I forget them all :o

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...