Summary of dos format conversion to unix format, dosunix

Source: Internet
Author: User

Summary of dos format conversion to unix format, dosunix

When we write a script in windows, submit it to the server, and update it, you will see that the file does not exist, but it does exist, what is the reason? It is actually caused by the file format, because after we write the code in windows, we update it to linux and its format is dos, so we need to convert this dos format to the same format as the system, that is, unix format:

1. When we use vim to open a file, if there is no prompt in the vim text editor after it is opened, the text format is the same as that of your system, if it appears below the vim Editor

"/Tmp/test" [dos] 3L, 71C indicates that the file format is dos and the system format is different, therefore, we need to convert the dos format of this file to the unix format. In the vim editor, you can convert dos to unix:

(1),: set fileformat = unix

: Write


(2): set ff = unix

: Write

In this way, we save and exit. After opening it, you will find that there is no dos in the vim editor ...... Format prompt, indicating that the format has been changed.


2. If the vim editor is not applicable, you can also use the dos2unix and unix2dos commands. To use these commands, you must first install dos2unix.

(1) format change command: dos2unix filename; so we can change it. In fact, this transformation process is to remove ^ M. Because the line breaks in windows and linux are different, ^ M is added in windows, so dos2unix is the process of removing ^ M.


3. The dos2unix command mentioned in 2 can be used only after it is installed. Therefore, we can implement the same functions as 2:

Set's/^ M // 'tlinux. sh> tmp_Tlinux.sh

Mv-f tmp_Tlinux.sh Tlinux. sh

Remove ^ M and rename it.



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.