How to split a file with adding sequence number and extension.

I have a file name -HRCFTSIN05PLA1602100430444444
my requirement is to split the file in 10000 count each file and to add sequence number.rch at the end of each file.
output should be in this format

HRCFTSIN05PLA160210043044444401.rch
HRCFTSIN05PLA160210043044444402.rch
HRCFTSIN05PLA160210043044444403.rch
HRCFTSIN05PLA160210043044444404.rch

plz help!@

Hi,

Try this,

#!/usr/bin/perl
$filename='HRCFTSIN05PLA1602100430444444';
for ( $i=1; $i<=10000 ; $i++ ) {
print "$filename$i.rch\n";
}

split :smiley:

try:

split -l 10000 -a 5 HRCFTSIN05PLA1602100430444444 splited_file
 
i=1
for file in splited_file*
do
 mv $file HRCFTSIN05PLA1602100430444444_${i}.rch
 i=$(( i + 1 ))
done

With awk:

awk 'NR % 10000 == 1 {ext=sprintf("%02d.rch", ++c)}
{print > FILENAME ext}
' HRCFTSIN05PLA1602100430444444