perl -Mstrict -Mwarnings -Mutf8 -CSD -e 'my $c=0; my $i=1; my $fn = sprintf("%010d",$i);open(FH,">",$fn)||die"open $fn,$!";while(<>){while(/(\X)/g){print FH "$1";if(++$c%3000==0){close(FH);$fn=sprintf("%010d",++$i);open(FH,">",$fn)||die"open $fn,$!";}}}close(FH);' < input.txt