File Format problems in Windows and Linux

Source: Internet
Author: User

2011-05-18 wcdj

 

Problem:


When you run the cat-V filename command in Linux to view files written in Windows, you can find that each line ends with a ^ m character. An unexpected error occurs when an application written in Linux reads a file containing ^ m characters. Therefore, you need to convert the file format in windows to the file format in Linux.

There are still doubts:


Open the file containing ^ m in my VI, and set: set list can only see the line break represented by "$", but not ^ m characters. Replacement with: %/^ m $/g is not found.

 

Note:
To get the ^ m do not actually enter it as is. insert it by typing the CTRL-V sequence instead.

Remove ^ m:


There are many ways to remove ^ m, which are summarized as follows:

Method 1:
To convert the file format in VI, run the following command: WQ.
: Set fileformat = Unix
: Set fileformat = DoS

Method 2:
Use the col command
Cat file_win | col-B> file_linux
Cat file_win | col-B | tee file_linux

Method 3:
Use the tr command
Cat file_win | tr-D'/R'> file_linux
Cat file_win | tr-D'/R' | tee file_linux

Refer:

Removing CRLF using vi
Http://phaq.phunsites.net/2006/07/25/removing-crlf-using-vi/

Why does my VI sometimes not display carriage return and line break characters in Windows ^ m
Http://bbs.chinaunix.net/viewthread.php? Tid = 757832

VI displays line breaks and other special symbols
Http://blog.163.com/mageng11@126/blog/static/14080837420110211753226/

Linux: Col Filter Control Character/seq Sequence Generation
Http://cicikasa.blog.163.com/blog/static/13757535520102495718203/

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.