Line breaks in Windows and Linux are not in the text file format.

Source: Internet
Author: User
Tags perforce

Simply put, the line feed of the window file is "/R/N", and the line feed of the Linux File is "/N". Therefore, there is a problem if you copy the file directly from the window to Linux. Use Vim to open the ^ m character at the end of each line.

However, a lot of software will directly deal with these differences. For example, notepad ++ will open the file. If it is found to be "/R" or "/R/N", a new line will be displayed. Perforce also handles this. For example, submit the file from window to perforce, and then synchronize the file from perforce to Linux/Unix, perforce automatically converts "/R/N" to "/N". Conversely, files are submitted from Linux to perforce and synchronized to Windows, this is perforce converting "/N" to "/R/N ".

Because these software processes different carriage return lines on different platforms, we seldom notice that. But sometimes the problem occurs in the invisible line breaks. So how to check?

You can use binary to view these files. For example, in Vim, %! Open xdd.

The following example of viewing binary data comes from the http://www.cnblogs.com/killkill/archive/2010/06/23/1763785.html

First, create a binary file:

1 [Oracle @ logserver TMP] $Echo -N"Abcdefghijklmnopqrstuvwxyz" >Test. Bin
2 [Oracle @ logserver TMP] $Cat Test. Bin
3 Abcdefghijklmnopqrstuvwxyz [Oracle @ logserver TMP] $

Note that ECHO must keep up with the-n option; otherwise, a line feed will be automatically added and test. Bin will be opened with vim.

View Source

Print?

1 [Oracle @ logserver TMP] $ vim-BTest. Bin

The-B Option of VIM tells Vim to open a binary file. If this parameter is not specified, 0x0a is added to the end, which is a line break.

In command mode, type:

View Source

Print?

1 : %! Xxd

If the-B option is not added to VIM, the hateful 0x0a will appear:

If option-B is available, this is not the case:

Then, change the edit mode. I will change the 41 and 42 values corresponding to a and B to 61 and 62, and change the 61 and 62 values corresponding to a and B to 41 and 42.

Return to the command mode and enter:

View Source

Print?

1 : %! Xxd-R

Now we can find that the positions of AB and AB are changed.

Finally, enter WQ in command mode to save and exit.

Learn about these differences and use appropriate tools to view them so that you can quickly troubleshoot or locate problems.

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.