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-B Test . 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?
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?
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.