How Linux Dos2unix and Unix2dos are used

Source: Internet
Author: User

We all know that the files on the Linux download to the Windows system on the format is messy, then what do we do? Now I teach you an easy way to solve the problem of file format chaos that can occur on a Linux system file download to a Windows system.

The Dos2unix command is used to convert a DOS-formatted text file into a UNIX-formatted (Dos/mac to UNIX text FileFormat converter). Dos text file is based on \ r \ n As the mark of the break, 16 binary is 0d0a. and the Unix text file is \ n as a break mark, which means that the 16 binary is 0A.

The DOS format text file under Linux, with the lower version of VI Open the end of the ^m will be displayed, and many commands are not very good processing of this format of the file, if it is a shell script. The UNIX-formatted text files are displayed together when opened with Notepad under Windows. As a result, there is a need to convert the two format files to each other, and the Unix2dos command that translates the UNIX format text file into a DOS format.

Unix2dos and Dos2unix


Name


Unix2dos-unix to DOS text file format converter

Synopsys Technology

Unix2dos [Options] [-C Convmode] [-o file ...] [-n infile file output ...]

Options:

[-HKQV] [--help] [-keepdate] [--quiet] [--Version]

Common parameters:

-K: Preserves the format of file shipping.

-N: Preserves the original old file and outputs the converted content to the new file.

Unix2dos Example:

Get input and output from stdin to standard output.

Unix2dos

Convert and replace A.txt. Convert and replace B.txt.

[R[email protected] ~]# unix2dos a.txt b.txt

[Email protected] ~]# Unix2dos- o a.txt b.txt

Convert and replace ASCII conversion modes in A.txt. Conversions and

Replaces the ISO conversion mode of the B.txt.

[Email protected] ~]# unix2dos a.txt-c ISO b.txt

[[email protected] ~]# unix2dos-c ASCII a.txt-c ISO b.txt

Convert and replace a.txt while maintaining the original date stamp.

[Email protected] ~]# unix2dos-k a.txt

[Email protected] ~]# unix2dos-k-o a.txt

Convert A.txt and Write E.txt.

[Email protected] ~]# unix2dos-n a.txt e.txt

Convert a.txt and write same, E.txt,e.txt hold date stamp

A.txt.

[Email protected] ~]# unix2dos-k-n a.txt e.txt

Convert and replace A.txt. Convert B.txt and Write E.txt.

[Email protected] ~]# Unix2dos a.txt-n b.txt e.txt

[Email protected] ~]# unix2dos-o a.txt-n b.txt e.txt

Convert C.txt and write to E.txt. Convert and replace A.txt. Transformation

and replace the b.txt. Convert D.txt and write to F.txt.

[Email protected] ~]# unix2dos-n c.txt e.txt-o a.txt b.txt-n d.txt f.txt

Dos2unix Example:

Get input and output from stdin to standard output.

Dos2unix

Convert and replace A.txt. Convert and replace B.txt.

[Email protected] ~]# Dos2unix a.txt b.txt

[Email protected] ~]# Dos2unix-o a.txt b.txt

Convert and replace ASCII conversion modes in A.txt.

[Email protected] ~]# Dos2unix a.txt-c ISO b.txt

Convert and replace the ISO conversion mode for B.txt.

[[email protected] ~]# dos2unix-c ASCII a.txt-c ISO b.txt

Mac C.txt translates in Unix ASCII format.

[Email protected] ~]# Dos2unix-c mac C.txt B.txt

Convert and replace a.txt while maintaining the original date.

[Email protected] ~]# dos2unix-k a.txt

[Email protected] ~]# dos2unix-k-o a.txt

Convert A.txt and Write E.txt.

[Email protected] ~]# dos2unix-n a.txt e.txt

Convert a.txt and write same, E.txt,e.txt hold date stamp

A.txt.

[Email protected] ~]# dos2unix-k-n a.txt e.txt

Convert and replace A.txt. Convert B.txt and Write E.txt.

[Email protected] ~]# Dos2unix a.txt-n b.txt e.txt

[Email protected] ~]# dos2unix-o a.txt-n b.txt e.txt

Convert C.txt and write to E.txt. Convert and replace A.txt. Transformation

and replace the b.txt. Convert D.txt and write to F.txt.

[Email protected] ~]# dos2unix-n c.txt e.txt-o a.txt b.txt-n d.txt f.txt


This article from "Dragon" blog, reproduced please contact the author!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.