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),点转换即可直接转换 注:支持命令提示符下参数操作 功能: unix文本文件与dos文本文件相互转换 1、unix文本转DOS文本...
dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的
unix2dos批量转换工具(双向) MS... 5、如果内置到其它程序,可能通过批处理调用,因为其支持DOS命令运行调用。具体看如下描述 功能:DOS=>UNIX UNIX=>DOS 运行环境:MS-WINDOWS,及DOS下 注:支持命令行参数调用
unix2dos/u2d unix转换成windows格式命令 dos2unix/d2u windows转换成unix格式命令 getclip 获取剪贴板内容 putclip 写入剪贴板内容
DOS、UNIX 经典命令集锦.rarDOS、UNIX 经典命令集锦.rar
dos2unix命令用来将DOS格式的文本文件转换成UNIX格式 最简单的用法就是dos2unix直接跟上文件名:dos2unix file -k:保持输出文件的日期不变 -q:安静模式,不提示任何警告信息。 -V:查看版本 -c:转换模式,模式有...
由于工作电脑网络限制无法安装unix2dos和dos2unix命令转换文件,自己实现一个 直接上代码,保存为python文件如unix2dos.py然后使用命令 unix2dos.py {unix2dos|dos2unix} {dirname|filename} #! /usr/bin/env ...
linux中没有dos2UNIX命令怎么解决办法,dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX ...因此产生了两种格式文件相互转换的需求,对应的将UNIX格式文本文件转成成DOS格式的是unix2dos命令。
1、由于windows平台与linux平台下的换行符不同,因此在不同平台间传送文件时,因经过转换,此工具即实现了此功能。 2、此资源包文件列表如下: a) unix2dos.c #unix2dos源... #命令格式:dos2unix <源文件> <目标文件>
dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX text file format converter)
Dos To Unix 编码转换工具
只要下载该安装包然后执行rpm -ivh unix2dos-2.2-35.el6.x86_64.rpm 以后就可以在linux下执行unix2dos命令
dos2unix命令用来将DOS格式的文本文件转换成UNIX格式的(DOS/MAC to UNIX text file format converter)。DOS下的文本文件是以\r\n作为断行标志的,表示成十六进制就是0D 0A。而Unix下的文本文件是以\n作为断行标志...
使用方法:拖放要转换的文本文件至输入窗口中,选择要转换的方式(DOS2UNIX或UNIX2DOS),点转换即可直接转换 注:支持命令提示符下参数操作 功能: unix文本文件与dos文本文件相互转换 1、unix文本转DOS文本...
dos、unix 经典命令集锦
设计任务 (1)为Windows操作系统建立兼容的DOS命令接口,文件与目录命令 (2)具体命令:DIR,RD,CD,MD,DEL,MOVE,REN,XCOPY,命令格式可参考Windows的CMD.EXE或MS-DOS提供的命令格式 (3)设计命令的名称,参数等...
使用方法:拖放要转换的文本文件至输入窗口中,选择要转换的方式(DOS2UNIX或UNIX2DOS),点转换即可直接转换 注:支持命令提示符下参数操作 功能: unix文本文件与dos文本文件相互转换 1、unix文本转DOS文本文件 ...
目标:为Windows操作系统建立一个兼容Unix命令的命令接口,实现命令包括ls,cat,cp,mv,md,rd,cd,sort,more命令。 环境:使用CodeBlock开发(g++编译) 效果:尚未发现BUG 优点:代码可读性高、比较精简、错误处理...