perl -pe 's/.*pattern\n$/<>for 1..3;$_/e' [download]
In reply to Re: Regex and writing lines in file by choroba in thread Regex and writing lines in file by amma