The format of line breaks for DOS/Windows and Linux/UNIX files is different. DOS/Windows-based text files have a Cr (line breaks) and LF (line breaks) at the end of each line ), UNIX text only has one line feed.
1) Move the files in DOS/Windows to Linux/Unix
Although manyProgramWe don't care about the DOS/Windows format Cr/LF text files, but there are several programs that care about it-the most famous is Bash. As long as we press enter, it will cause problems. The following sed calls convert DOS/Windows text to a trusted UNIX format:
$ Sed-E's/. $ // 'mydos.txt> myunix.txt
The script works very easily: the replacement rule expression matches the last character of a row, and the character is exactly the carriage return. We can replace it with an empty character to completely delete it from the output. If you use this script and
Note that the last character of each line in the output has been deleted, you have specified a text file that is already in UNIX format. So there is no need to do that!
2) Move the Linux/UNIX text to the Windows system and use the following script to perform the required format conversion:
$ Sed-E's/$ // R/'myunix.txt> mydos.txt
In this script, the '$' rule expression matches the end of the row, and '/R' tells sed to insert a carriage return before it. Insert a carriage return before line feed. Immediately, each line ends with Cr/LF. Note that '/R' is replaced with CR only when GNU sed 3.02.80 or later is used '.