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

How to delete carriage return characters from text in Linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article introduces the relevant knowledge of "how to delete the carriage return character in the text in Linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The "enter" character can be traced back a long time-there was a mechanism or lever on the typewriter that moved the frame of the paper roller to the right so that the letter could be re-entered on the left. They kept it on a text file on Windows, but never used it on Linux systems. This incompatibility can sometimes cause problems when you try to work with files created on Windows on Linux, but it's a very easy problem to solve.

If you use the od (octal dump octal dump) command to view the file, the enter (also represented by Ctrl+M) character will be displayed as octal 15. The character CRLF is commonly used to indicate a sequence of carriage returns and newline characters at the end of a line in an Windows text file. Those who pay attention to octal dumps will see\ r\ n. By contrast, Linux text ends only with a newline character.

Here is an example of od output that highlights the CRLF character on the line, as well as its octal.

$od-bc testfile.txt0000000 124 150 151 163 040 151 163 040 141 141 040 164 145 163 040 146 T h i s i s a test f0000020 151 154 145 040 162 157 155 040 127 151 151 156 157 167 163 ile f r o m Window s0000040 056 012 111 164 047 163 040 144 146 146 145 162 145 156

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

Servers

Wechat

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

12
Report