File Format Conversion between DOS, windows, and Linux/Unix -- include. h :???????? Solution

Source: Internet
Author: User
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 '.

Related Article

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.