(go) How to cancel the ^m symbol displayed under Linux, VI

Source: Internet
Author: User

Transferred from: http://www.cnblogs.com/dkblog/archive/2012/02/03/2337187.html

"Background knowledge"

^m is the ' \ R ' in ASCII, and the carriage return is 16 binary 0x0d,8 015, decimal 13.

For this action, UNIX generally has only one 0x0a to represent line breaks, and Windows is generally 0x0d and 0x0a two characters.

In addition: ^l is an ASCII 0x0C ' \f ', a page-break control.

For Linux VI, some versions, such as my current development Board in the VI, is compiled with BusyBox, can not be recognized under the Windows editing, with 0x0d of those text files, so you edit a normal text file under Windows, if there is a newline, Then in the VI of Linux, the corresponding 0x0d will show a ^m, such as:

1. LED On & Off^m
Eg.^m
echo None >/sys/class/leds/led_green/trigger^m
Echo 1 >/sys/class/leds/led_green/brightness^m
echo >/sys/class/leds/led_green/brightness^m
Note:the default switch of trigger is [none]^m
2. Heartbeat Flash^m
Eg.^m
echo Heartbeat >/sys/class/leds/led_green/trigger^m
3. Timer Flash^m
Eg.^m
echo Timer >/sys/class/leds/led_green/trigger^m
Echo 5 >/sys/class/leds/led_green/delay_on^m
Echo 5 >/sys/class/leds/led_green/delay_off^m

Each line finally has a ^m, it is ugly, so want to remove.

Note: The normal PC version of Linux, as if it can be well recognized, such as my linux server, openSUSE, a version of the VI, can be very good to display those edited under Windows, with 0x0d of the carriage return line character, cannot appear ^m.

In addition, with respect to ASCII characters, Linux has a brief introduction below:

[[email protected] wi-fi]$ manASCII

ASCII (7) Linux Programmer ' s Manual ASCII (7)

NAME

Ascii-the ASCII Character set encoded in octal, decimal, and hexadecimal

DESCRIPTION

ASCII is the American standard Code for information interchange. It is a 7-bit code. Many 8-bit codes (such as ISO 8859-1, the Linux default character set) contain ASCII as their lower half. The international counterpart of ASCII is known as ISO 646.

The following table contains the ASCII characters.

C program ' \x ' escapes is noted.

Oct Dec hex Char Oct Dec hex Char

------------------------------------------------------------------------

0 NUL ' 100 64 40 @

001 1 SOH (start of heading) 101 A

002 2 STX (start of text) 102

003 3 ETX (end of text) 103

004 4 EOT (end of transmission) 104-D

005 5 ENQ (Enquiry)

006 6 ACK (acknowledge) 106 F

007 7 BEL ' \a ' (Bell) 107 G

010 8 BS ' \b ' (backspace)

011 9 HT ' t ' (horizontal tab) 111

012 0A LF ' \ n ' (new line) 4 a J

013 0B VT ' \v ' (vertical tab) 113 4 B K

014 0C FF ' \f ' (Form feed) 4C L

015 0D CR ' r ' (carriage ret) 4D M

016 0E SO (Shift-out) $4E N

017 0F SI (shift in) 117 4F O

。。。。。。。。。。。

"How to eliminate the ^m in VI"

I have just started to use the SED command:

Sed ' s/^m//g ' file_old > File_new

Unsuccessful, the output of the file, with vi open, or with ^m.

Later on the internet to find a way to use, with the TR command:

Tr-d "\015" < myfile.txt > Myfile_new.txt

You can remove the symbol ^m (that is, "\015") and save it as a new file Myfile_new.txt

(go) How to cancel the ^m symbol displayed under Linux, vi

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.