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

dos2unix和unix2dos命令使用【转】的更多相关文章

  1. linux中没有dos2UNIX或者UNIX2dos命令怎么解决办法

    linux中没有dos2UNIX或者UNIX2dos命令怎么解决办法 http://blog.csdn.net/w616589292/article/details/38274475 dos2unix ...

  2. 如何在 CentOS 上安装 dos2unix 和 unix2dos 命令

    yum install -y dos2unix 注意:以上安装包既包含 dos2unix 命令,又包含 unix2dos 命令.

  3. linux中没有dos2UNIX或者UNIX2dos命令解决办法

    安装方法: 在http://linux.softpedia.com/progDownload/Dos2Unix-Download-5519.html下载hd2u-1.0.0.tgz [root@loc ...

  4. 【Linux常见命令】dos2unix命令,unix2dos命令

    我们都知道.打回车键就是换行的意思. 在不同系统下打回车键效果是不同的: MAC OS下:dakdhih \r LINUX下:dakdhih \n DOS\WINDOWS下:dakdhih \r\n ...

  5. dos2unix、diff命令

    一.dos2unix:将DOS格式文件转化成UNIX格式文件 语法: dos2unix [选项] [文件...] [-n INFILE输出文件...]           unix2dos [选项] ...

  6. dos2unix和unix2dos

    dos2unix将windows格式的文件转换为linux格式的文件. unix2dos将linux格式的文件转换为windows格式的文件. dos2unix和unix2dos会转换windows和 ...

  7. dos2unix与unix2dos之学习记录

    1. unix2dos与dos2unix这两个tool是用来干什么的? 这首先应该要说明一下背景知识: unix类操作系统下,换行字符是\n: 而早期的dos操作系统,其换行字符是由\r\n组成. 所 ...

  8. [转] 将DOS格式文本文件转换成UNIX格式

    点击此处阅读原文 用途说明 dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX text file format converter).DOS下的文本文 ...

  9. 常用的vi快捷方式

    一般情况来说: 0代表行首,$代表行末 $,G代表最后一行 光标移动 0 移动到本行最前面 $ 移动到本行最后 G 移动文件最后一行 nG 移动到文件第n行 gg 移动到文件第一行 n[space]移 ...

随机推荐

  1. ivew Modal rule校验冲突问题

    问题描述:新建和编辑公用的是一个弹框,打开新建关闭之后,会影响到编辑的弹框.  解决方法:赋值前先重置一下表单  this.$refs["你的表单"].resetFields();

  2. Vue学习之路第二篇:插值表达式

    要开始写Vue的功能了,是不是很激动呢!开始吧! 1.首先建立一个html页面,导入Vue js包 <script type="text/javascript" src=&q ...

  3. thinkphp queue

    composer create-project topthink/think composer require topthink/think-queue php think queue:work -- ...

  4. vuex中mutations与actions的区别

    要执行vuex中的函数,有两种方法: 1.commit,例如this.$store.commit("GETMODULESELECTLIST"); //mutations中的方法 2 ...

  5. (56) 解决字段设为readonly无法保存

    问题描述:当一个字段设为readonly =True 后,在form表单,即使你用onchange方法改变了值但也不能保存到数据库当时.平时在这样的要求,form表单有些字段要展示给用户,但又要达到不 ...

  6. JavaScript 实现留言框

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  7. 如何让Jboss的debug在myeclise上运行

    1.在windows下运行jboss的debug.bat 看见监听的端口 2.打开myeclipse 点击选择 ①你要配置的名字(随意) ②myeclipse中选中该项目 ③jboss的启动的ip地址 ...

  8. 【 【henuacm2016级暑期训练】动态规划专题 G】 Palindrome pairs

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 先用枚举回文串中点的方法. 得到这个字符串中出现的所有的回文. 得到他们的左端点以及右端点. 整理成一个pair<int,in ...

  9. POJ——T 3159 Candies

    http://poj.org/problem?id=3159 Time Limit: 1500MS   Memory Limit: 131072K Total Submissions: 33328   ...

  10. jQuery判断浏览器类型和版本

    jquery 判断浏览器类型 例:   if($.browser.msie) { alert("这是一个IE浏览器"); }else if($.browser.opera) { a ...