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. BZOJ 4619 Swap Space 解题报告

    今天是因为David Lee正好讲这个题的类似题,我才做了一下. 本题是world final 2016的一道水…… 题目地址如下 http://www.lydsy.com/JudgeOnline/p ...

  2. python 学习笔记6(函数)

    函数 定义: 函数是指将一组语句的集合通过一个名字(函数名)封装起来,要想执行这个函数,只需调用其函数名即可 特性: 1.减少代码重复 2.保持代码的一致性 3.方便修改,可扩展性 函数的创建 #简单 ...

  3. String类型中ToString hashCode equals compareTo等方法的经典实现

    private final char value[]; private int hash; // Default to 0 public String(String original) { this. ...

  4. prototype和__proto__

    一.prototype和__proto__的概念 prototype是函数的一个属性(每个函数都有一个prototype属性),这个属性是一个指针,指向一个对象.它是显示修改对象的原型的属性. __p ...

  5. linux常用命令之文件系统

    df df - report file system disk space usage 查看文件系统的使用清空 用法 df [-hi] [path] 选项 -h human readable ,以人类 ...

  6. 双重OAuth 2.0架构

    OAuth 2.0支持几种grant type,由于安全性不同,所以适用范围也不同.背景知识:<理解OAuth 2.0> grant type 是否需要secret 是否出现授权界面 授权 ...

  7. phonegap安卓手机开发入门

    先安装安卓开发安环境 http://www.cnblogs.com/zhangsanshi/p/3582368.html 安装phonegap 在安装ant http://www.cnblogs.co ...

  8. 钉钉客户端JS-API权限签名算法.NET版

    前段时间写了一篇博文<钉钉如何进行PC端开发>,在里面并未解决本地生成签名的问题,需要到官网进行生成,由于钉钉门票等认证信息会超期,因此,必须能本地用代码自动更新相关参数信息,来换取签名. ...

  9. FormsAuthentication身份认证源代码

    使用FormsAuthentication类可以实现身份认证功能,这里提供一个asp.net项目的源代码,项目名称KWS.项目实现了登录.退出和判断身份的功能. 关于项目 点击这里下载源代码 http ...

  10. 浅谈float浮动

    float大概是css3以前网页布局里最常用的一个属性了,经常看到一言不合就浮动的代码,就一起来深入挖掘一下这个一半天使一半魔鬼的属性吧. 本文是读张鑫旭大神慕课网float视频后的一些总结及一些拓展 ...