依睛(IT blog) 我回来了,PHP<-->C/C++ LINUX

笨鸟

统计

积分与排名

友情连接

最新评论

(重点)文件行尾有^M的解决方法

源地址: http://blog.chinaunix.net/u1/42517/showart_440963.html
不得不说的重点!!!!!!!!!!!!!!!!!!!!



文件行尾有^M的解决方法
在cublog主页上看到有人写了一个去掉linux下文件行尾有^M的解决办法,我也说一个,呵呵。
这个主要是由于linux文件与windows文件格式不同造成的。有一个叫dos2unix的软件可以解决这个问题,先搜一下看看需要些什么吧:

$ apt-cache search dos2unix

嗯,列出来了:

sysutils - Miscellaneous small system utilities - dummy package tofrodos - Converts DOS <-> Unix text files, alias tofromdos

好,开始装吧:

$ apt-get install sysutils tofrodos

软件很小,一会儿就装完了。

以后再碰到windows文件放到linux下出现^M现象的就容易多了:

$ dos2unix filename

如果linux文件在windows下显示不好的,也可以用这个东西转一下:

$ unix2dos filename

 发表于: 2007-12-12,修改于: 2007-12-12 15:58 已浏览506次,有评论2条 推荐 投诉

  网友评论
 crook 时间:2008-06-06 14:25:50 IP地址:199.64.0.★
Another way:

add the following to ~/.bashrc
# DOS -> Unix file format
alias dcr='sed -e "s/\r//g" -i'

Then you can use the command like this:
dcr filename

 NKLOVERENE 时间:2008-06-07 13:38:35 IP地址:125.38.26.★
是哈是哈
多谢

posted on 2008-11-28 23:36 向左向右走 阅读(760) 评论(0)  编辑 收藏 引用 所属分类: C/C++学习资料库

只有注册用户登录后才能发表评论。