How do I see whether a file is in DOS or UNIX format?

Source: Internet
Author: User
I. BACKGROUND

Because Windows and Linux do not have the same identity, code delivery from different systems can cause changes in the code format that could lead to problems with the program failing to compile properly. Therefore, according to some compiled error prompts, you can navigate to a file format problem, you want to convert the program's text file.

Second, the solution

The end of the Windows identity line is a carriage return line feed, which is ' \ r \ n ', also called CRLF. Linux's identification of the end of a line is only a newline, that is, ' \ n ', which is LF. When you copy a program from Windows to Linux, you only need to format all the files using the following command (see [1]).

   find . -type f -exec dos2unix {} \;

Third, the method of viewing file type 3.1windows using notepad++, you can set the display of all characters (refer to [2]), notepad++ the lower right corner will show the file type.

Use vim under 3.2linux (reference [3])

Using VIM to open the file, enter: Set FF?. The file type can be based on the returned result

Use gedit under 3.3linux

Use Gedit to open the file and search for ' \ r \ n ' to see if the end of each line exists. The presence is usually a DOS type, and the UNIX type does not exist.

Iv. Reference Documents

[1]linux-dos2unix command on entire directory-stack Overflow

[2]3.10. notepad++ supports display of carriage returns, line breaks, tab keys, beginning of line, end of lines and other special characters

[3] File Format-vim Tips Wiki

How do I see whether a file is in DOS or UNIX format?

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.