dos2unix, unix2dos 用来实现 DOS <=> UNIX text file 转换
aptitude install sysutils
行末:
DOS 格式 0d 0a
UNIX 格式 0a

可用功能相同的指令組合
dos2unix:
sed -i'' "s/\r//" file

cat file | col -b > newfile

cat file | tr -d "\r" > newfile

cat file | tr -d "\015" > newfile

unix2dos:
sed -i'' "s/$/\r/" file

sed -i'' "s/$/\x0d/" file

-i后面的是单引号组成

以上适用 GNU sed, FreeBSD 下的 sed 不适用

------------------------------------------

dos2unix 命令

这是一个很简单的命令.功能是将DOS/MAC下的文件转化为UNIX的文本文件格式.用法详见下面.
就是这样一个简单的命令折腾了我大半天.我在用mysql查询数据库,执行的批处理放在了一个文件里.如果我执行这个文件,那个存放查询结果的 文件名字总是在后面附加一个?号.而如果我一行一行敲入命令,执行就正常.而且比较了两个文件后没有差别.还有一个奇怪的事情就是总是出现一个类似 "quit"出现mysql语法错误的提示.这个奇怪的现象使我很困惑.后来在一位老大的帮助下想到了是不是由于文件格式的差别.因为我这个文件在 windows下编辑过,后来一试,果然很灵啊.

SYNOPSYS
       dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...]
       Options:
       [-hkqV] [--help] [--keepdate] [--quiet] [--version]

DESCRIPTION
       dos2unix, the program that converts plain
       text files in DOS/MAC format to UNIX format.

OPTIONS
       The following options are available:

-h --help
              Print online help.

-k --keepdate
              Keep the date stamp of output file same as input file.

-q --quiet
              Quiet mode. Suppress all warning and messages.

-V --version
              Prints version information.

-c --convmode convmode
              Sets conversion mode. Where convmode is one of: ASCII, 7bit,
              ISO, Mac with ASCII being the default. Simulates dos2unix under
              SunOS.
-o --oldfile file ...
              Old file mode. Convert the file and write output to it. The pro-
              gram default to run in this mode. Wildcard names may be used.

-n --newfile infile outfile ...
              New file mode. Convert the infile and write output to outfile.
              File names must be given in pairs and wildcard names should NOT
              be used or you WILL lost your files.

EXAMPLES
       Get input from stdin and write output to stdout.

dos2unix

Convert and replace a.txt. Convert and replace b.txt.

dos2unix a.txt b.txt

dos2unix -o a.txt b.txt

Convert and replace a.txt in ASCII conversion mode.
dos2unix a.txt -c iso b.txt

Convert and replace b.txt in ISO conversion mode.

dos2unix -c ascii a.txt -c iso b.txt

Convert c.txt from Mac to Unix ascii format.

dos2unix -c mac c.txt b.txt

Convert and replace a.txt while keeping original date stamp.

dos2unix -k a.txt

dos2unix -k -o a.txt

Convert a.txt and write to e.txt.

dos2unix -n a.txt e.txt

Convert a.txt and write to e.txt, keep date stamp of e.txt
same as
       a.txt.

dos2unix -k -n a.txt e.txt

Convert and replace a.txt. Convert b.txt and write to e.txt.

dos2unix a.txt -n b.txt e.txt

dos2unix -o a.txt -n b.txt e.txt

Convert c.txt and write to e.txt. Convert and replace a.txt. Convert
       and replace b.txt. Convert d.txt and write to f.txt.

dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt

最新文章

  1. Unity3D 摄像机的Transform通过摇杆输出的方向
  2. java回调初步学习
  3. Web大文件上传控件-jsp-sql示例更新-Xproer.HttpUploader6.2
  4. HDU 4122 Alice&#39;s mooncake shop --RMQ
  5. 苹果app审核的规则总结
  6. linux下的文件系统
  7. Shared Preferences 数据存储
  8. DataTable常用操作
  9. Magento中,调用静态块的几种方法
  10. java_spring_List,Map,Properties,Set注入与遍历
  11. 字符串:各种奇葩的内置方法 - 零基础入门学习Python014
  12. 强烈推荐visual c++ 2012入门经典适合初学者入门
  13. System Request 进入KDB模式过程详解
  14. C4.cpp
  15. webform之Repeater控件
  16. 使用JFinal实现使用MVC获取表单中的数据并将提示信息返回给另一jsp页面。
  17. HTTP笔记(二)
  18. OOP——构造函数、析构函数
  19. Devexpress TreeList 展开和折叠当前选中节点
  20. SQL server 添加主外键约束

热门文章

  1. JTree知识小点
  2. ELK搭建和部署-----(上半部分)
  3. vue实现双向绑定原理
  4. Myeclipse学习总结(9)——MyEclipse2014安装插件的几种方式(适用于Eclipse或MyEclipse其他版本)
  5. 楼宇自控-RS232\RS485\RS422
  6. Struts2学习(四)利用ajax异步上传
  7. jdk1.8Option类
  8. Maven传递依赖的时候,同名包不同版本号的包均会下载,可是编译的时候,仅仅会载入一个高版本号的。
  9. kibana智能检索发送多次_msearch —— 配置index pattern,同时设置时间段,就知道到底是在哪些索引里去查找数据了
  10. vue引入swiper vue使用swiper vue脚手架使用swiper /引入js文件/引入css文件