Skip to main content
2 of 2
OP wants to read a fixed file...
vonbrand
  • 18.6k
  • 2
  • 40
  • 63

Perl is ideally suited to this... following is untested, but should work.

Edit: Modified to read a fixed file.

#!/usr/bin/perl

open IN, "< this_is_input";
open OUT, "> before_ER";
while(<IN>) {
  if(/^\d+\sER\s\d+/$) {
     # Line containing <number><spaces>ER<spaces><number> only
     chomp;
     close OUT;
     open OUT, "> $_";
  }
  else {
    print $OUT;
  }
}
vonbrand
  • 18.6k
  • 2
  • 40
  • 63