Line breaks are different for Windows and Linux. The runtime on a generic operating system automatically determines the wrapping format for text files. If a program runs on Windows, it generates CR/LF text files, while running on Linux generates a text file for the LF format for line wrapping. Using a file file with another line break on one platform can cause unexpected problems, especially when editing program code. Sometimes the code appears normal in the editor, but when you edit it, it goes wrong because of the newline character problem. Many text/code editors have a newline character conversion feature that allows you to swap line breaks in a text file with different formats.
When using FTP software to transfer files between different platforms, in ASCII text mode, some FTP client programs automatically convert to the line format. The number of bytes of file that has been transferred may vary. If you do not want FTP to modify the original file, you can use bin mode (binary mode) to transfer text.
Solution: After Linux with Dos2unix filename conversion once, successfully solve the problem.
The Dos2unix command is used to convert a DOS-formatted text file to a UNIX-formatted (Dos/mac to UNIX text files format converter). The text file in DOS is marked as a break mark in Rn, and is represented as 16 in 0D 0 A. The text file under UNIX is marked with n as the break mark, which is represented as 16 in 0 a. DOS format text files under Linux, open at the end of a lower version of VI will show ^m, and many commands are not very good to handle this format file, if it is a shell script. Text files in UNIX format are displayed together when opened with Notepad in Windows. As a result, there is a need to convert two format files to each other, and the corresponding conversion of UNIX-formatted text files into DOS format is the Unix2dos command.
Common parameters:
The simplest way to convert a DOS format text file into a UNIX format is to dos2unix the file name directly.
Format: Dos2unix file
If you convert multiple files at once, follow these file names directly after Dos2unix. (Note: can also add-o parameter, also can not add, the effect is the same)
Format: Dos2unix file1 file2 file3
Format: Dos2unix-o file1 file2 file3
The above is converted directly on the original file, if you want to save the results of the transformation in other files, and the source file does not change, you can use the-n parameter.
Format: Dos2unix oldfile newfile
If you want to keep the file timestamp unchanged, add the-k argument. So a few of the above commands are able to add a-K parameter to keep the file timestamp.
Format: Dos2unix-k file
Format: dos2unix-k file1 file2 file3
Format: dos2unix-k-o file1 file2 file3
Format: dos2unix-k-n oldfile newfile
Note: The Unix2dos command is used in a similar manner to the Dos2unix command.
Cat-v can see nonprinting characters in the file without the cat command with the-v argument.
Hexdump-c can see the hexadecimal representation of each byte of the file.