Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Remove the ^ M symbol displayed in the file

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Remove the ^ M symbol background displayed in the file

For files edited under windows, the ^ M symbol sometimes appears when opened with vim under Linux.

Principle

The contents of this section are referred to [1]

Vim is configured as fileformat=unix, and the files you open are in dos format. The newline character in unix format is 0A (ascii code), that is, the newline character in dos format is 0D 0A (that is,), which is actually displayed as ^ M.

Think back to the prehistory of computers, when typewriters used two characters to start a new line. First, a character command moves the print head back to the start position (enter,), and then another character command controls the feed line (feed,).

In the early days of computers, storage devices were very expensive. So it is suggested that there is no need to use two characters to indicate the end of a line:

The UNIX family decided to use only one feed character to represent the end of the line. People from Apple's mac camp use carriage return as the standard for changing lines. MS-DOS (and Microsoft's Windows) still decided to follow the old tradition of carriage return.

This also means that if you move files from one system to another, you will encounter problems associated with line breaks.

Solution method

Today, I stumbled upon a good way to remove ^ M:

Specify the filename: sed-I "s /\ srabbit plaza g" filename all the files in the current directory: sed-I "sr /\ srabbit racket placca g" `ls`

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report