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