Chinaunix首页 | 论坛 | 博客
  • 博客访问: 155126
  • 博文数量: 19
  • 博客积分: 901
  • 博客等级: 准尉
  • 技术积分: 268
  • 用 户 组: 普通用户
  • 注册时间: 2010-01-14 23:58
文章分类

全部博文(19)

文章存档

2010年(19)

我的朋友

分类:

2010-05-31 12:08:51

Dos 格式的文件,用 0D 0A (CR+LF)作为换行符,而Unix 的则是以0A(LF) 作为换行符,所以dos 底下的文本文件到了unix的话,换行符就会多出来一个 0D(CR) 显示为 ^M 。

2 。解决方法:
a. 传输时使用 ftp 的 asc mode
b. DOS/WIN中用编辑工具,转换成Unix格式再传到Unix
c. 直接用unix 提供的dos2unix 工具
[php]
man dos2unix
Reformatting page.  Please Wait... done

User Commands                                         dos2unix(1)

NAME
     dos2unix - convert text file from DOS format to ISO format

SYNOPSIS
     dos2unix [-ascii] [-iso] [-7] [-437 | -850 | -860 |  -863  |
     -865]  originalfile convertedfile

DESCRIPTION
     The dos2unix utility converts characters in the DOS extended
     character set to the corresponding ISO standard characters.

     This command can be invoked from either DOS or  SunOS.  How-
     ever,  the  filenames must conform to the conventions of the
     environment in which the command is invoked.

     If the original file and the converted file  are  the  same,
     dos2unix will rewrite the original file after converting it.

...
[/php]
当然,也有unix2dos工具……
4。用vi / sed 也可进行替换
s/^M$//
阅读(3536) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~