Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Linux dos2unix and unix2dos

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

We all know that the file format on Linux is chaotic when it is downloaded to Windows system, so what should we do? Now I will teach you a simple way to solve the Linux system files downloaded to the Windows system will appear file format chaos situation.

The dos2unix command is used to convert DOS/MAC to UNIX text fileformat converter. Under DOS, text files are marked with\r\n as a line break, expressed as hexadecimal is 0D0A. Under Unix, text files are marked with\n as a line break, expressed as hexadecimal is 0A.

DOS-formatted text files under Linux will show ^M at the end of the line when opened with lower versions of vi, and many commands will not work well with this format if it is a shell script. Unix-formatted text files are displayed together when opened with Notepad under Windows. This creates the need to convert files between the two formats. The corresponding command to convert UNIX text files to DOS format is unix2dos.

unix2dos and dos2unix

name

unix 2dos UNIX to DOS text file format converter

Xinsi Technology

unix2dos [options] [-c convmode] [-o file...] [-n output of infile file...]

Options:

[-hkqV][- -Help][-keepdate][- -Quiet][- -Version]

Common parameters:

-k: Preserve the format in which the document was delivered.

-n: Keep the original old file and export the converted content to the new file.

unix2dos example:

Get input and output from stdin and write to standard output.

unix2dos

Convert and replace a.txt. Convert and replace b.txt.

[root@localhost ~]# unix2dos a.txt b.txt

[root@localhost ~]# unix2dos -o a.txt b.txt

Convert and replace ASCII conversion patterns in a.txt. conversion and

Replace ISO conversion mode for b.txt.

[root@localhost ~]# unix2dos a.txt-c iso b.txt

[root@localhost ~]# unix2dos -c ascii a.txt -c iso b.txt

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

[root@localhost ~]# unix2dos -k a.txt

[root@localhost ~]# unix2dos -k -o a.txt

Convert a.txt and write e.txt.

[root@localhost ~]# unix2dos -n a.txt e.txt

Convert a.txt and write same, e.txt, e.txt keep date stamp

a.txt。

[root@localhost ~]# unix2dos -k -n a.txt e.txt

Convert and replace a.txt. Convert b.txt and write e.txt.

[root@localhost ~]# unix2dos a.txt -n b.txt e.txt

[root@localhost ~]# unix2dos -o a.txt -n b.txt e.txt

Convert c.txt and write e.txt. Convert and replace a.txt. conversion

and replace b.txt. Convert d.txt and write f.txt.

[root@localhost ~]# unix2dos -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt

dos2unix example:

Get input and output from stdin and write to standard output.

dos2unix

Convert and replace a.txt. Convert and replace b.txt.

[root@localhost ~]# dos2unix a.txt b.txt

[root@localhost ~]# dos2unix -o a.txt b.txt

Convert and replace ASCII conversion patterns in a.txt.

[root@localhost ~]# dos2unix a.txt -c iso b.txt

Convert and replace ISO conversion modes for b.txt.

[root@localhost ~]# dos2unix -c ascii a.txt -c iso b.txt

Mac c.txt to Unix ascii format.

[root@localhost ~]# dos2unix -c mac c.txt b.txt

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

[root@localhost ~]# dos2unix -k a.txt

[root@localhost ~]# dos2unix -k -o a.txt

Convert a.txt and write e.txt.

[root@localhost ~]# dos2unix -n a.txt e.txt

Convert a.txt and write same, e.txt, e.txt keep date stamp

a.txt。

[root@localhost ~]# dos2unix -k -n a.txt e.txt

Convert and replace a.txt. Convert b.txt and write e.txt.

[root@localhost ~]# dos2unix a.txt -n b.txt e.txt

[root@localhost ~]# dos2unix -o a.txt -n b.txt e.txt

Convert c.txt and write e.txt. Convert and replace a.txt. conversion

and replace b.txt. Convert d.txt and write f.txt.

[root@localhost ~]# dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report