perl -pi.bak -e 'BEGIN{1 while <> !~ /PATTERN/ and !eof}' filename