Find pattern in a file and erase it

Hello,

I'd like to find pattern in a file and erase line containing that pattern and 2 lines below that pattern. I know how to find pattern with grep -r pattern and erase line containing that pattern, but can't figure out the rest, how to erase 2 lines below that pattern line. Any suggestions?

Thank you in advance

one way:

 awk '{if ($0 ~/pattern/) {getline; getline; continue}
            else print }'  old.txt > new.txt

it would be awesome if it worked I get some kind of error "awk: (FILENAME=old.txt FNR=126) fatal: `continue' outside a loop is not allowed" any help ? thank you

My bad - you want 'next', not continue.

its ok jim I found solution elsewhere but thank you anyways :slight_smile:

sed -i.bak '/pattern/{N;N;d;}' file