Special Characters [^M] appearing at the end of line in file if seen on unix but not when seen in eclipse

后端 未结 5 1951
梦毁少年i
梦毁少年i 2020-12-21 23:53

As described in questions, if I see a file in unix then I see special characters in it like ^M at the end of every line but if I see same file in eclipse than I

相关标签:
5条回答
  • 2020-12-22 00:10

    Perhape this has suppressed UNIX warning message and worked creating the output file:

    $ dos2unix -437 file.txt > file2.txt
    
    0 讨论(0)
  • 2020-12-22 00:11

    You have saved your text file as a DOS/Windows text file. Some Unix text editors do not interpret correctly DOS/Windows newline convention by default. To convert from Windows to Unix, you can use dos2unix, a command-line utility that does exactly that. If you do not have that available in your system, you can try with tr, which is more standard, using the following invocation:

    tr -d '\r' < input.file > output.file
    
    0 讨论(0)
  • 2020-12-22 00:22

    This are windows new line chars. You can follow steps shown in this post to have correct this issue.

    0 讨论(0)
  • 2020-12-22 00:31

    They are probably Windows carriage return characters. In Windows, lines are terminated with a carriage-return character followed by an end-of-line character. On Unix, only end-of-line characters are normally used, therefore many programs display the carriage return as a ^M.

    You can get rid of them by running dos2unix on the files. You should also change your Eclipse preferences to save files with Unix end of lines.

    0 讨论(0)
  • 2020-12-22 00:33

    You can remove those using dos2unix utility on a linux or unix machine. The syntax is like this dos2unix filename.

    0 讨论(0)
提交回复
热议问题