It isn't very hard to do in Perl if you can't find a suitable alternative (and it will perform pretty well):
#!/usr/bin/env perl
use strict;
use warnings;
# Configuration items - could be set by argument handling
my $prefix = "rs."; # File prefix
my $number = 1; # First file number
my $width = 4; # Number of digits to use in file name
my $rx = qr/^\+$/; # Match regex
my $limit = 3; # 50,000 in real case
my $quiet = 0; # Set to 1 to suppress file names
sub next_file
{
my $name = sprintf("%s%.*d", $prefix, $width, $number++);
open my $fh, '>', $name or die "Failed to open $name for writing";
print "$name\n" unless $quiet;
return $fh;
}
my $fh = next_file; # Output file handle
my $counter = 0; # Match counter
while (<>)
{
print $fh $_;
$counter++ if (m/$rx/);
if ($counter >= $limit)
{
close $fh;
$fh = next_file;
$counter = 0;
}
}
close $fh;
That's far from being a one-liner; I'm not sure whether that's a merit or not. The items that should be configured are grouped together, and could be set via command line options, for example.
You could end up with an empty file; you could spot that and remove it if necessary. You'd need a second counter; the existing one is a 'match counter' but you'd also need a line counter, and if the line counter was zero at the you'd remove the last file. You'd also need the name to be able to remove it...fiddly, but not difficult.
Give the input (basically two copies of your sample data), the output from repsplit.pl
(repeat split) was as shown:
$ perl repsplit.pl data
rs.0001
rs.0002
rs.0003
$ cat data
entry 1
some more
+
entry 2
some more
even more
+
entry 3
some more
+
entry 4
some more
+
entry 1
some more
+
entry 2
some more
even more
+
entry 3
some more
+
entry 4
some more
+
$ cat rs.0001
entry 1
some more
+
entry 2
some more
even more
+
entry 3
some more
+
$ cat rs.0002
entry 4
some more
+
entry 1
some more
+
entry 2
some more
even more
+
$ cat rs.0003
entry 3
some more
+
entry 4
some more
+
$