Linux Doc by: zollty
The files written in notepad in windows are different from those written in vim or gedit in Linux!
For example, an SH script written in Windows may fail to be executed in Linux.
Solution:
The reason is: in windows, the line feed is "\ r \ n", while in Linux, "\ n" is not "\ r". When the shell file is written in windows, all linefeeds are "\ r \ n". The file cannot be executed in shell, and the above error is prompted. Run "file-> conversions-> DOS to Unix" in ultraedit. The converted sh file can be directly executed in Linux. In this step, the "\ r" symbol can be canceled.
Select ASCII on the client side.
If transfer has been completed using binary, Then skip the following steps:
Cat ms.txt | col-B> linux.txt
Files created in Linux will be crowded together (without line breaks) when opened in notepad in windows ), the reason is that notepad does not support \ n line breaks (it only supports line breaks in the \ r \ n format ),
Solution:
Save the file to the doc format and use word to open the file. In this way, use vim or gedit in Linux to create a DOC file (a pure text DOC file) (or create a new doc file. c documentation. You can use vc6.0 in Windows to browse !). To open the file, you can directly enter the command: (Note: if the file name is Chinese, it may not be found. You need to perform the LS operation, copy the file name, and then paste the file name in gedit)
Gedit xx.doc
Or Vim xx.doc (not recommended. Vim may not support traditional Chinese characters)
You can also directly find the file, click it, open it with open office, select character set (system), character (sysong18030), language (Simplified Chinese), and change the paragraph:
1. CR & lf, that is, \ r \ n, which is in the notepad format in windows and fully supported by Linux. (recommended)
2. cr, that is, \ r, not supported by notepad. There is no line feed effect or \ r effect. Word has line feed effect or \ r effect. Its \ r effect is: at the end of each row, the default cursor is positioned as the first line of the next line, that is, the content entered at the end of the line is actually the first line of the next line, and \ r is the real line feed. While \ n is the carriage return, the original intention is that the paper of the typewriter moves down one bit. Later, in Linux/Unix systems, \ n became the actual line break.
3. Lf, that is, line breaks in Linux/Unix systems.
If the DOC file is written in Windows, it is usually garbled in Linux to view it (using open office,
Solution:
Open it with open office, select all, and set the font to sysong18030. OK is displayed in both Simplified Chinese and Traditional Chinese.
\ R is a carriage return, \ n is a line break, and each system has a line break:
Win with \ r \ n
Linux/Unix \ n
Mac OS \ r
Cr is represented by '\ R'. the ASCII code in decimal format is 13 and the hexadecimal code is oxod.
Lf uses the '\ n' symbol. the ASCII code is 10 and the hexadecimal value is 0x0a.
Therefore, in windows, oa od is used, that is, CR & lf,
Linux/Unix uses OA, that is, lf
MacOS uses OD, that is, Cr
Origin: before the computer appeared, there was a kind of device called teletype model 33, which can contain 10 characters per second. But there is a problem, that is, when a line breaks a line, it takes 0.2 seconds, just two characters. If a new character is passed in the 0.2 s, the character will be lost.
As a result, the developers thought of a way to solve this problem, that is, adding two end characters after each line. One is "enter", which tells the typewriter to position the print head on the left boundary, and the other is "line feed", which tells the typewriter to move the paper down one line. This is the source of "line feed" and "Carriage Return". They can also be seen in their English names.
Later, computers were invented, and these two concepts were invented on computers. At that time, memory was very expensive. Some scientists thought it would be too waste to add two characters at the end of each line. Just add one character. As a result, there were differences. In Unix systems, each line ends with "<line feed>", that is, "\ n". In Windows systems, each line ends with "<press enter> <line feed> ", that is, "\ r \ n". In MAC systems, the end of each line is "<press enter> ". One direct consequence is that if a file in UNIX/MAC is opened in windows, all the text will be changed to a line; if a file in Windows is opened in UNIX/MAC, A ^ m symbol may be added at the end of each line.
(When FTP software is used to transmit files between different platforms, some FTP client programs automatically convert the line feed format in ASCII text transmission mode. the number of bytes transmitted may change. if you do not want to modify the original file over FTP, you can use the bin mode (binary mode) to transfer text)
Use of \ n and \ r in C language:
# Include <stdio. h>
Int main ()
{
Printf ("938517 \ r10086 \ n ");
Return 0;
}
Whether in Linux or windows, the input is
10086
Because \ r has a line break, 938517 is no longer displayed. \ N is not a line feed in the real sense. It actually moves the paper (or screen) One by one (to show the content of the next line ).