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.