您的位置:首页 > 运维架构 > Linux

Linux常用命令--dos2unix

2016-06-29 16:54 525 查看
1.功能:DOS/MAC文件转化成UNIX文件格式,功能跟notepad编辑器下的编辑-文档格式转换-转换为UNIX格式一样
2.安装方式:yum install -y dos2unix
3.语法:
dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...]
4.参数:
-h --help 帮助
-k --keepdate 时间戳保持不变
-q --quiet 静默模式,不输出告警和信息
Quiet mode. Suppress all warning and messages.
-c --convmode 设定转化模式,模式有:ASCII, 7bit, ISO
-o --oldfile file 默认模式,将转换后的文件直接写到原文件中
-n --newfile infile outfile 将infile中的内容写入到outfile中
5.例子
[mysql@mysql ~]$ ls -lh
total 12K
-rw-r--r--. 1 root root 31 Jun 29 15:43 echo_test.sh
-rw-r--r--. 1 root root 18 Jun 29 15:41 test.txt
-rw-r--r--. 1 mysql dba 68 Jun 23 22:47 week.txt
#中间把test.txt、week.txt删除#
[mysql@mysql ~]$ dos2unix -k echo_test.sh
dos2unix: converting file echo_test.sh to UNIX format ...
[mysql@mysql ~]$ ls -lh

total 4.0K
-rw-r--r--. 1 mysql dba 30 Jun 29 15:43 echo_test.sh#时间戳未变

[mysql@mysql ~]$ dos2unix echo_test.sh
dos2unix: converting file echo_test.sh to UNIX format ...
[mysql@mysql ~]$ ls -lh
total 4.0K
-rw-r--r--. 1 mysql dba 30 Jun 29 16:03 echo_test.sh#时间戳变化
[mysql@mysql ~]$ dos2unix -n echo_test.sh test.sh
dos2unix: converting file echo_test.sh to file test.sh in UNIX format ...
[mysql@mysql ~]$ ls -lh
total 8.0K
-rw-r--r--. 1 mysql dba 30 Jun 29 16:03 echo_test.sh
-rw-r--r--. 1 mysql dba 30 Jun 29 16:03 test.sh
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Linux dos unix