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 linux deletes the last few lines

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to delete the next few lines of linux". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to delete the next few lines of linux".

Linux delete the last few lines: 1, use the "sed $(($Amuri 3: 1)), ${A} d a.txt" command to delete the last few lines of the file; 2, use the "sed '2d`-I aa.txt" command to delete all lines from line 2 to the end of the file.

This article operating environment: linux5.9.8 system, Dell G3 computer.

How does linux delete the next few lines?

Linux deletes the last few lines of the file:

1.

[root@server ~] # cat aa.txtaaaabbbbccccddddeeee [root@server ~] # sed $(sed-n'$= 'a.txt) [root@server ~] # sed $(($Amuri 3: 1)), ${A} d a.txt [root@server ~] # cat aa.txtaaaa

Or use the above two commands. The last three lines are deleted.

If you delete the countdown 300, just change 3 to 300.

two。

-I is to be modified on the original file. If you don't need to modify it, you don't need I.

Among them, sed'2 was named "I aa.txt".

This command deletes all lines from line 2 (including line 2) to the end of the file.

Note:

Command one operates the original file, resulting in newly generated files everywhere or printed to the screen

The second command is to directly manipulate the original file, as a result, the original file has been changed, resulting in the command result.

Thank you for reading, the above is the content of "how to delete the next few lines of linux", after the study of this article, I believe you have a deeper understanding of how to delete the next few lines of linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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