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

Linux removes\ r from the file under windows.

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

Share

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

In the Unix system, there is only "", or "\ n" at the end of each line.

In the Windows system, each line ends with "", that is, "\ n\ r".

A direct result is that if a file under the Unix system is opened in Windows, all the text will become one line.

If the file in Windows is opened under Unix, there may be an extra ^ M symbol at the end of each line.

Method 1:

In command mode: enter:% s / ^ M / / g and then enter to replace the note, where the input of "^ M" is generated by "Ctrl+v" and "Ctrl+M" keys, respectively.

Method 2:

Use vi to open a text file in vi dos.txt command mode enter: set fileformat=unix:w

Method 3:

Use the sed tool sed's / ^ M / / 'filename > tmp_filename

Method 4:

Since there are more carriage returns under window, of course, by deleting'\ rcarriage', it can also be achieved: tr-d'\ r'.

Method 5: (the most commonly used method)

Press the command under the terminal: $dos2unix filename is directly converted into unix format, and then OK! ~

Sed-I's /\ r Compact 'startup.sh

The default is\ r\ nlinux\ nunix\ r under window.

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