The dos file is put on linux and the solution to the ^ M problem is displayed.

Source: Internet
Author: User
Put the dos file on linux and display ^ M solution-general Linux technology-Linux technology and application information. The following is a detailed description. Several methods for removing ^ M
1. cat filename1 | tr-d "\ r"> newfile

2. sed-e "s/^ V ^ M //" filename> outputfilename

3. vi: open a file with vi

1. Press ESC

2. Input: % s/^ M/g

Confirm ^ M is to use "CTRL-V CTRL-M" instead of literally ^ M. This regular expression will replace ^ M before all carriage return characters with null ($ is used to ensure ^ M appears at the end of the row)

4. Some linux versions include the dos2unix program, which can be used to remove ^ M

5. Use vim

Input: set notextmode

Unfortunately, after the above processing, ^ M does not exist, but the line feed fails. Everything is on one line, and it is very difficult to look at it. This indicates that the file is missing "\ n" during processing. You can add it when replacing it:

Cat filename | tr "\ r" "\ n"> newfile
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.