In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The cause of the problem:
Under linux, it is inevitable to use VIM to open some edited text files under windows. We will find that there is a ^ M symbol at the end of each line of the file, because the editor under DOS and the Linux editor have inconsistent handling of the carriage return at the end of the file line, and the definition of the carriage return:
Windows:0D0A
Unix\ linux: 0A
MAC: 0D
Files in DOS, Mac and Unix format recall 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 the Apple 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. The Vim editor can recognize these files in different formats.
Solution:
Use regular expressions to replace full-text characters in command mode:
:% s / ^ M / / g
The input of "^ M" is generated by the "Ctrl+v" and "Ctrl+M" keys, respectively. Control characters like ^ M are control characters in VIM, and control characters must be entered in another way in finding and replacing, that is, when entering ^ M, you must type Ctrl+V and Ctrl+M on the keyboard in turn.
two。 Use the sed tool
$sed-e's /\ x0D mydebug.c mydebug.c > temp_mydebug.c23
3. The simplest way to use the dos2unix tool
$sudo apt-get install dos2unix$ dos2unix README.txt
Reference documentation:
How to solve the ^ M in the open file in VIM
Vim open file has ^ M ending
Find replacement control characters in Vim
On the solution to the appearance of ^ M in opening files with vim in linux
A brief Analysis of Linux Command dos2unix
Dos2unix download
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.