1. 直接用 vim 编辑器打开文件,然后把字符串 "^M" 替换成空的就可以了。命令如下:
输入 : 号进入底行模式,然后输入: %s/\r//g ,再 Enter 就可以了。
2. 使用现成的工具。命令如下:
dos2unix hello.c
新系统如果没有这个工具,可以安装:
apt-get install tofrodos
使用介绍:
Use "fromdos" to convert DOS text files to the Unix format, and "todos" to convert Unix text files to the DOS format.
转换为unix,命令为:
fromdos hello.c
转换为dos,命令为:
todos hello.c
如果还有新的更好的方法,可以评论补充哦~~ :-D