Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting N lines from every start point

How would I delete the 6 lines starting from every instance of a word i see?

like image 898
syker Avatar asked Jan 22 '23 22:01

syker


1 Answers

I think this sed command will do what you want:

sed '/bar/,+5d' input.txt

It removes any line containing the text bar plus the five following lines.

Run as above to see the output. When you know it is working correctly use the switch --in-place=.backup to actually perform the change.

like image 87
Mark Byers Avatar answered Jan 28 '23 21:01

Mark Byers