Monday, May 6, 2024
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 1169  / 3 Years ago, sat, may 22, 2021, 3:26:27

I want to know how to quickly delete text with Bash. For example, I have a file named file.txt with a total of 500 lines.


I want to delete lines 80 to 146 - how do I do that?


What's is a terminal command that can do that?


More From » command-line

 Answers
4

With awk to print in terminal:


awk 'NR < 80 || NR > 146' file.txt

Or with gawk to edit file in-place:


gawk -i inplace 'NR < 80 || NR > 146' file.txt

[#110] Sunday, May 23, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
wenceslockro

Total Points: 494
Total Questions: 127
Total Answers: 97

Location: Chad
Member since Mon, Dec 5, 2022
1 Year ago
wenceslockro questions
Sat, May 7, 22, 07:11, 2 Years ago
Mon, Nov 22, 21, 10:31, 3 Years ago
Tue, May 16, 23, 02:58, 1 Year ago
;