Conversion of DOS format to UNIX format summary

Source: Internet
Author: User

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

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.