Skip to main content
OP wants to read a fixed file...
Source Link
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;
  }
}

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

#!/usr/bin/perl

open OUT, "> before_ER";
while(<>) {
  if(/^\d+\sER\s\d+/$) {
     # Line containing <number><spaces>ER<spaces><number> only
     chomp;
     close OUT;
     open OUT, "> $_";
  }
  else {
    print $OUT;
  }
}

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;
  }
}
Source Link
vonbrand
  • 18.6k
  • 2
  • 40
  • 63

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

#!/usr/bin/perl

open OUT, "> before_ER";
while(<>) {
  if(/^\d+\sER\s\d+/$) {
     # Line containing <number><spaces>ER<spaces><number> only
     chomp;
     close OUT;
     open OUT, "> $_";
  }
  else {
    print $OUT;
  }
}