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$//
阅读(3604) | 评论(0) | 转发(0) |