When we write a script under Windows, after the submission to the server, after the update, when you run the time you will see that the file does not exist, but that the file does exist, that is what the reason, is actually the format of the file caused, because we in the Windows After writing, we update to the Linux writing when her format or dos so we want to convert this DOS format to the same format as the System UNIX format:
1, when we use VIM to open a file, if you open after the Vim text editor does not have any hint that the format of the text and your system is consistent, if it appears below the VIM editor
"/tmp/test" [dos] 3L, 71C such a hint of the word that the format of the file is DOS and the system format is different, so we want to convert the file's DOS format to UNIX format. The ways to convert Dos to UNIX in the Vim editor are:
(1),: Set Fileformat=unix
: Write
(2), : Set Ff=unix
: Write
So we save the exit, after this opens you will find there is no DOS under the VIM editor ... The format hint, stating that the format was changed.
2, if it is not applicable to the Vim editor can also use Dos2unix, unix2dos these commands, the premise of using these commands is that we first want to install Dos2unix.
(1), Format change command: Dos2unix filename; So we're going to turn around. In fact, the process of this transformation is to remove ^m. Because Windows and Linux under the different line characters, under Windows is more ^m so Dos2unix is to remove the ^m process.
3, in 2 said the Dos2unix command first installed in order to use so we can implement and 21-like function:
Set ' s/^m//' tlinux.sh >tmp_tlinux.sh
Mv-f tmp_tlinux.sh tlinux.sh
This will remove the ^m and then rename it.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Conversion of DOS format to UNIX format summary