我們都知道Linux上的文件下載到windows系統(tǒng)上格式就亂了, 那我們怎么辦那 ?現(xiàn)在我教大家一個簡單的方法來解決Linux系統(tǒng)的文件下載到windows系統(tǒng)上會出現(xiàn)的文件格式亂的情況。
dos2unix命令用來將DOS格式的文本文件轉(zhuǎn)換成UNIX格式的(DOS/MAC to UNIX text fileformat converter)。DOS下的文本文件是以\r\n作為斷行標(biāo)志的,表示成十六進(jìn)制就是0D0A.而Unix下的文本文件是以\n作為斷行標(biāo)志的,表示成十六進(jìn)制就是0A.
DOS格式的文本文件在Linux底下,用較低版本的vi打開時行尾會顯示^M,而且很多命令都無法很好的處理這種格式的文件,如果是個shell腳本。而Unix格式的文本文件在Windows下用Notepad打開時會拼在一起顯示。因此產(chǎn)生了兩種格式文件相互轉(zhuǎn)換的需求,對應(yīng)的將UNIX格式文本文件轉(zhuǎn)成成DOS格式的是unix2dos命令。
unix2dos 和 dos2unix
名稱
unix2dos-UNIX 到 DOS 文本文件格式轉(zhuǎn)換器
新思科技
unix2dos [選項] [-c convmode] [-o 文件......][-n infile 文件的輸出......]
選項:
[-hkqV][— — 幫助][-keepdate][— — 安靜][— — 版本]
常用參數(shù):
-k :保留文件運來的格式。
-n :保留原本的舊文件,將轉(zhuǎn)換后的內(nèi)容輸出到新文件。
unix2dos 例子:
從 stdin 中獲得輸入和輸出寫到標(biāo)準(zhǔn)輸出。
unix2dos
轉(zhuǎn)換和替換 a.txt。轉(zhuǎn)換和替換 b.txt。
[root@localhost ~]# unix2dos a.txt b.txt
[root@localhost ~]# unix2dos -o a.txt b.txt
轉(zhuǎn)換和替換 a.txt 中 ASCII 轉(zhuǎn)換模式。轉(zhuǎn)換和
替換 b.txt 的 ISO 轉(zhuǎn)換模式。
[root@localhost ~]# unix2dos a.txt-c iso b.txt
[root@localhost ~]# unix2dos -c ascii a.txt -c iso b.txt
轉(zhuǎn)換和替換 a.txt 同時保持原始日期戳。
[root@localhost ~]# unix2dos -k a.txt
[root@localhost ~]# unix2dos -k -o a.txt
轉(zhuǎn)換 a.txt 和寫入 e.txt。
[root@localhost ~]# unix2dos -n a.txt e.txt
轉(zhuǎn)換 a.txt 和寫入相同,e.txt,e.txt 保持日期戳
a.txt。
[root@localhost ~]# unix2dos -k -n a.txt e.txt
轉(zhuǎn)換和替換 a.txt。轉(zhuǎn)換 b.txt 和寫入 e.txt。
[root@localhost ~]# unix2dos a.txt -n b.txt e.txt
[root@localhost ~]# unix2dos -o a.txt -n b.txt e.txt
轉(zhuǎn)換 c.txt 并寫入 e.txt。轉(zhuǎn)換和替換 a.txt。轉(zhuǎn)換
和替換 b.txt。轉(zhuǎn)換 d.txt 并寫入 f.txt。
[root@localhost ~]# unix2dos -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
dos2unix 例子:
從 stdin 中獲得輸入和輸出寫到標(biāo)準(zhǔn)輸出。
dos2unix
轉(zhuǎn)換和替換 a.txt。轉(zhuǎn)換和替換 b.txt。
[root@localhost ~]# dos2unix a.txt b.txt
[root@localhost ~]# dos2unix -o a.txt b.txt
轉(zhuǎn)換和替換 a.txt 中 ASCII 轉(zhuǎn)換模式。
[root@localhost ~]# dos2unix a.txt -c iso b.txt
轉(zhuǎn)換和替換 b.txt 的 ISO 轉(zhuǎn)換模式。
[root@localhost ~]# dos2unix -c ascii a.txt -c iso b.txt
Mac c.txt 轉(zhuǎn)換 Unix ascii 格式中。
[root@localhost ~]# dos2unix -c mac c.txt b.txt
轉(zhuǎn)換和替換 a.txt 同時保持原始日期。
[root@localhost ~]# dos2unix -k a.txt
[root@localhost ~]# dos2unix -k -o a.txt
轉(zhuǎn)換 a.txt 和寫入 e.txt。
[root@localhost ~]# dos2unix -n a.txt e.txt
轉(zhuǎn)換 a.txt 和寫入相同,e.txt,e.txt 保持日期戳
a.txt。
[root@localhost ~]# dos2unix -k -n a.txt e.txt
轉(zhuǎn)換和替換 a.txt。轉(zhuǎn)換 b.txt 和寫入 e.txt。
[root@localhost ~]# dos2unix a.txt -n b.txt e.txt
[root@localhost ~]# dos2unix -o a.txt -n b.txt e.txt
轉(zhuǎn)換 c.txt 并寫入 e.txt。轉(zhuǎn)換和替換 a.txt。轉(zhuǎn)換
和替換 b.txt。轉(zhuǎn)換 d.txt 并寫入 f.txt。
[root@localhost ~]# dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
分享名稱:Linuxdos2unix和unix2dos是的使用方法-創(chuàng)新互聯(lián)
本文地址:http://aaarwkj.com/article28/dsjdjp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化、微信公眾號、動態(tài)網(wǎng)站、網(wǎng)站改版、虛擬主機、關(guān)鍵詞優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容