特殊字符[^ M]出现在文件末尾,如果在unix上看到但在Eclipse中看不到 [英] Special Characters [^M] appearing at the end of line in file if seen on unix but not when seen in eclipse

查看:2032
本文介绍了特殊字符[^ M]出现在文件末尾,如果在unix上看到但在Eclipse中看不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如问题中所述,如果我在unix中看到一个文件,那么我会看到其中的特殊字符,如每个行的末尾的 ^ M ,但如果我看到相同的文件在日食比我看不到那个特殊的字符。

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 do not see that special characters.

如果我使用eclipse编辑文件,我该如何删除文件中的这些字符,我们必须在eclipse首选项中进行相同的具体更改吗?

How can I remove those characters in the file, if am using eclipse for editing the file, do we have to make any specific changes in the eclipse preferences for the same ?

任何指导都将非常感激。

Any guidance would be highly appreciated.

更新:

是的确是运输问题,以下命令帮助我得到它:

Yes indeed it was carriage issue and following command helped me to get it sort out:

dos2unix file1.sh> file2.sh file2 .sh 将是该文件,它不会有任何载入值。

dos2unix file1.sh>file2.sh and file2.sh will be the file and it will not have any carriage values.

可能我们可以收到警告,如

Possibly we can get warning like

无法打开/ dev / kbd得到键盘类型美国键盘假设
无法获得键盘类型US键盘假定
,但按照命令将抑制警告:

could not open /dev/kbd to get keyboard type US keyboard assumed could not get keyboard type US keyboard assumed but following command will suppress the warnings:

dos2unix -437 file1.txt> file2.txt

推荐答案

文本文件作为DOS / Windows文本文件。默认情况下,某些Unix文本编辑器不能正确解释DOS / Windows换行符约定。要从Windows转换为Unix,您可以使用 dos2unix ,这是一个执行此操作的命令行实用程序。如果您的系统中没有可用的,可以尝试使用以下调用更标准的 tr

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

这篇关于特殊字符[^ M]出现在文件末尾,如果在unix上看到但在Eclipse中看不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆