dos2unix用法

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

时间: 2024-08-03 21:10:19

dos2unix用法的相关文章

dos2unix详解

Linux命令之dos2unix - 将DOS格式文本文件转换成UNIX格式 dos2unix安装 首先说明dos2unix是将dos文本转换为unix文本,不是将gbk转换为utf8,跟文本的编码格式没有关系. dos文本跟unix文本的主要区别是换行的区别,dos中用\r\n表示换行,而unix中用\n表示.所以dos文本在unix下每行结尾都会有一个^M. centos下直接安装dos2unix-3.1-37.el6.x86_64.rpm http://pkgs.org/centos-6-

dos2unix

dos2unix 实际上就是把文本文件里面的^M删除,我一般懒得用这个命令,vi里面用一个命令(:%s/^m//g)删除即可. 用法举例: dos2unix a.txt b.txt 要把一批文件都dos2unix,可以用下面的for语句: for f in *.txt do dos2unix $f temp_111 mv temp_111 $f done 参见http://wenda.so.com/q/1381616108060914

Linux命令之dos2unix

Linux命令之dos2unix (2011-09-22 11:24:06) 转载▼ 标签: 杂谈   Linux命令之dos2unix - 将DOS格式文本文件转换成UNIX格式 用途说明 dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX text file format converter).DOS下的文本文件是以\r\n作为断行标志的,表示成十六进制就是0D 0A.而Unix下的文本文件是以\n作为断行标志的,表示成十六进制就是 0A.DO

iconv,enconv,enca,convmv,unix2dos,dos2unix文件格式转换,od/cut/wc/dd/diff/uniq/nice/du等命令

1.在Vim中查看文件编码 :set fileencoding 即可显示文件编码格式. 如果你只是想查看其它编码格式的文件或者想解决 用Vim查看文件乱码 的问题,那么你可以在 ~/.vim rc 文件中添加以下内容: set encoding=utf-8 fileencodings=ucs-bom,utf-8,cp936 这样,就可以让vim自动 识别文件编码(可以自动识别UTF-8或者GBK编码的文件),其实就是依照fileencodings提供的编码列表尝试,如果没有找到合适的编码,就用l

vim编辑器用法

Vim 在linux的世界中,绝大多数配置文件是以ASCII的纯文本形式存在,(什么是纯文本文件:其实文件记录的就是1或者0,而我们通过编码系统将这些0或者1转换成我们认识的文字就是了) 为何要学习vim? 1.所有的unix like系统都会内置vi文本编辑器,其他的文本编辑器不一定存在: 2.很多软件的编辑接口都会主动调用vim: 3.Vim具有程序编程能力,可以主动以字体颜色辨别语法的正确性,方便程序设计: 4.编程简单,编辑速度相当快速: Vim分为三种模式:一般模式:命令模式:编辑模式

Linux命令之dos2unix - 将DOS格式文本文件转换成UNIX格式 用途说明

dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX text file format converter).DOS下的文本文件是以\r\n作为断行标志的,表示成十六进制就是0D 0A.而Unix下的文本文件是以\n作为断行标志的,表示成十六进制就是 0A.DOS格式的文本文件在Linux底下,用较低版本的vi打开时行尾会显示^M,而且很多命令都无法很好的处理这种格式的文件,如果是个shell脚本,.而Unix格式的文本文件在Windows下用Not

dos2unix命令

dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX text file format converter).DOS下的文本文件是以\r\n作为断行标志的,表示成十六进制就是0D 0A.而Unix下的文本文件是以\n作为断行标志的,表示成十六进制就是0A.DOS格式的文本文件在Linux底下,用较低版本的vi打开时行尾会显示^M,而且很多命令都无法很好的处理这种格式的文件,如果是个shell脚本,.而Unix格式的文本文件在Windows下用Note

dos2unix命令详解

基础命令学习目录首页 原文链接:https://blog.csdn.net/leedaning/article/details/53024290 使用git 的时候碰到git将unix换行符转换为windows换行符的问题,需要使用dos2unix命令将文件转换为unix格式. dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX text file format converter).DOS下的文本文件是以\r\n作为断行标志的,表示成十六进制就是

文件及内容处理之iconv、dos2unix

文件及内容处理 - iconv.dos2unix 1. iconv:转换文件的编码格式 iconv命令的功能说明 iconv 命令是 linux 下用于文件转编码的常用命令,对于同时使用 windows 系统和 linux 系统的同学来说文件转编码也是经常遇到的操作. iconv命令的语法格式 iconv [OPTION] [files]iconv [选项...] [文件...] iconv命令的常用参数说明: iconv 参数很多,表1为 iconv 命令的参数及说明: 表1: iconv 命