Suppose I have a file of the following file:
drink
eat
XXX
pizza
blunzn
sushi
I would like to delete all lines from the file, starting from the third line after the template XXX, so the result should look like this:
drink
eat
XXX
pizza
blunzn
Deleting all the lines after is XXXquite simple:
sed -e '/XXX/q' -i data.txt
However, it is difficult for me to skip a fixed number of lines after deleting the template.
The best I've come up with so far:
sed -e '/XXX/ { N; N; q }' -i data.txt
Is there anything more elegant than adding n * N(imagine I'd like to skip 50 lines)
source
share