Linux under ^m

Source: Internet
Author: User

Use VI under Linux to see some text files created under Windows, and sometimes find some "^m" at the end of the line. There are several ways to handle this.

Note: Under Linux, the ^m character can be typed through ctrl+v,ctrl+m, but the ^min the regular expression must be typed in this way, otherwise the regular expression does not match ^m Characters, so you cannot copy and paste the following code directly.

  1. Use the Dos2unix command. A gadget that comes with the system.
    Dos2unix yourfile.txt #去掉末尾的 ^m
  2. Use the Replace function of VI. Start VI, enter command mode, and enter the following command:
    :%s/^m//g # Remove all the ^m
  3. Use the SED command.
    $ Sed-e ' s/^m//g ' yourfile.txt

Linux under ^m

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.