in reply to Replacing Lines in 100 Gig file

just delete all <root>,</root> and <?xml...> after the second line and add a </root> at the end.
perl -pi.bak -e 'next unless $. > 2; s{</?root>\s*}{}; s{<\?xml.*\?>\s +*}{};' foo.xml echo '</root>' >> foo.xml
can't quite figure out how to leave that last </root> alone or how to add it at the end of processing...