UNIXtextfile轉換aptitudeinstallsysutils行末:D" />

日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

dos2unix和unix2dos命令使用 - [〓 腳本功略 〓

系統 3324 0

dos2unix和unix2dos命令使用 - ★〓 無用的天地 〓★ - 博客大巴

dos2unix和unix2dos命令使用 - [ 〓 腳本功略 〓 ]

2008-04-20

版權聲明 :轉載時請以超鏈接形式標明文章原始出處和作者信息及 本聲明
http://solecjj.blogbus.com/logs/19425369.html

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命令使用 - [〓 腳本功略 〓]


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 饶河县| 平顺县| 秭归县| 社旗县| 宣武区| 定襄县| 满洲里市| 葫芦岛市| 汾西县| 昌黎县| 亚东县| 响水县| 敦煌市| 宁南县| 晋城| 安阳县| 积石山| 平潭县| 吐鲁番市| 大田县| 韶山市| 雅安市| 屯门区| 鄂尔多斯市| 阳东县| 油尖旺区| 准格尔旗| 铜川市| 永宁县| 金塔县| 陇川县| 独山县| 阳朔县| 庐江县| 桃园县| 灌阳县| 阿坝| 北海市| 体育| 罗江县| 三门县|