1 . UNIX 下与 DOS 下回车键定义的不同
--使用 man tofrodos 可以获得以下信息
DOS text files traditionally have carriage return and line feed pairs as their newline characters
while Unix text files have the line feed as their newline character .(意思是,dos文本文档因袭传统, 把
carriage return 和line feed 的组合作为换行符;然而,unix 文本文件把line feed 作为换行符)
--通常把carrige return 和 line feed 分别写作 CR 和 LF ; 其中, CR 本用于将光标回退到当前行首;LF用于向下一行
CR 字符形式'/r' LF字符形式'/n';ascii 码值分别为10进制的13 和 10
--使用cat命令并加以 -A 选项可以呈现所有不可打印字符 ,其中包括回车符(newline character(s))
dos文件回车符显示为 ^M$
unix文件回车符显示为 $
unix文件回车符用两个字符表示 /r/n
dos 文件回车符用一个字符表示 /n
2 . unix 与 dos 文本文档格式转换工具
--名称 todos fromdos 函数(ubuntu环境)
--安装方法 $sudo apt-get install tofrodos
--函数格式 todos [options] [file]
fromdos [options] [file]
--函数选项
-b 将源文件file备份位file.bak