windows下编写的脚本,上传到linux上执行,有时会出现莫名其妙的结果,也是折腾了半天才找出原因,windows和linux有些编码不同,经dos2unix处理后,结果一切正常
man dos2unix结果如下,英文不难理解,一看就基本懂,所以也懒得翻译了
NAME
       dos2unix - DOS/MAC to UNIX text file format converter

SYNOPSYS
       dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...]

Options:

[-hkqV] [--help] [--keepdate] [--quiet] [--version]

DESCRIPTION
       This  manual page documents 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 program 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 lose 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用法的更多相关文章

  1. Linux命令dos2unix 从windows转换到linux --- nuix2dos从linux转换到windows

    dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX text file format converter).DOS下的文本文件是以\r\n作为断行标志的 ...

  2. dos2unix 命令

    最近在学习shell编程,可是在<Linux程序设计>指定的网站上下载了源码,使用的时候却一直出问题.提示:"bash: ./here1:/bin/sh^M:损坏的解释器: 没有 ...

  3. dos2unix

    dos2unix 实际上就是把文本文件里面的^M删除,我一般懒得用这个命令,vi里面用一个命令(:%s/^m//g)删除即可. 用法举例: dos2unix a.txt b.txt 要把一批文件都do ...

  4. Linux命令之dos2unix

    Linux命令之dos2unix (2011-09-22 11:24:06) 转载▼ 标签: 杂谈   Linux命令之dos2unix - 将DOS格式文本文件转换成UNIX格式 用途说明 dos2 ...

  5. Shell之sed用法 转滴

    通过例子学习sed的用法 1,sed介绍    sed可删除(delete).改变(change).添加(append).插入(insert).合.交换文件中的资料行,或读入其它档的资料到 文> ...

  6. iconv内容,convmv文件名,unix2dos,dos2unix文件格式转换,od/cut/wc/dd/diff/uniq/nice/du等命令,linux文件名乱码,文件名,文件内容,vim编码设置

    1.enconv文件名编码转换,比如要将一个GBK编码的文件转换成UTF-8编码,操作如下 enconv -L zh_CN -x UTF-8 filename enconv -L GB2312 -x  ...

  7. dos2unix与unix2dos之学习记录

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

  8. Shell命令-文件及内容处理之iconv、dos2unix

    文件及内容处理 - iconv.dos2unix 1. iconv:转换文件的编码格式 iconv命令的功能说明 iconv 命令是 linux 下用于文件转编码的常用命令,对于同时使用 window ...

  9. dos2unix详解

    Linux命令之dos2unix - 将DOS格式文本文件转换成UNIX格式 dos2unix安装 首先说明dos2unix是将dos文本转换为unix文本,不是将gbk转换为utf8,跟文本的编码格 ...

随机推荐

  1. 配置WCF Test Client

    用vs2010建立了一个wcf项目,通过F5直接运行那服务文件,就出现了一个”The dependent tool 'svcutil.exe' is not found“, , 之后想通过“tool- ...

  2. long和BigDecimal引发的管理思考

    关于long.double.BigDecimal在效率.可用性.灵活性等等方面的技术性讨论和测试其实在网上已经很多了,本文也不是打算讨论他们的实现的,其实笔者也曾在很长的职业生涯周期中一度拘泥于此.但 ...

  3. JavaScript学习(1):基础

    这篇文章里,我们来聊一些JavaScript的基础知识. 1. 如何运行JavaScript? JavaScript是一种解释型的语言,它不需要提前编译.通常情况下,JavaScript会放在网页中, ...

  4. 使用 SVG 制作单选和多选框动画【附源码】

    通过 JavaScript 实现 SVG 路径动画,我们可以做很多花哨的东西.今天我们要为您介绍一些复选框和单选按钮效果.实现的主要思路是隐藏原生的输入框,使用伪元素创造更具吸引力的样式,输入框被选中 ...

  5. 15个最佳的代码评审(Code Review)工具

    代码评审可以被看作是计算机源代码的测试,它的目的是查找和修复引入到开发阶段的应用程序的错误,提高软件的整体素质和开发者的技能.代码审查程序以各种形式,如结对编程,代码抽查等.在这个列表中,我们编制了1 ...

  6. HTML5 Content Editable实践

    基于此开发文档:https://developer.mozilla.org/zh-CN/docs/Web/Guide/HTML/Content_Editable 问题:通过contenteditabl ...

  7. jsom sharepoint 2010 循环获取多个list的item值

    <script type="text/javascript"> // <![CDATA[ var chongdianbaId; var elm = documen ...

  8. [Android]解决ClickableSpan中点击后ListView中item的长按冲突的问题

    以下内容为原创,转载请注明: 来自天天博客:http://www.cnblogs.com/tiantianbyconan/p/3823429.html 项目中碰到一个问题,情景是这样的: 有一个Lis ...

  9. 在android用Get方式发送http请求

    烦人的日子终于过去啦,终于又可以写博客啦,对自己的android学习做个总结,方便以后查看...... 一.在android用Get方式发送http请求,使用的是java标准类,也比较简单. 主要分以 ...

  10. 一起来学习Android自定义控件1

    概述 Android已经为我们提供了大量的View供我们使用,但是可能有时候这些组件不能满足我们的需求,这时候就需要自定义控件了.自定义控件对于初学者总是感觉是一种复杂的技术.因为里面涉及到的知识点会 ...