Split and rename files

Hello,

Need to split files into n number of files and rename the files

Example:

Input:

transaction.txt.1aa
transaction.txt.1ab
......

Output:

transaction.txt.1
transaction.txt.2
transaction.txt.3

-Thanks

have you looked at "split"

 
split -l 100 inputfile.txt output_prefix_

takes inputfile.txt ... and creates files:

 
output_prefix_aa
output_prefix_ab
output_prefix_ac
.. 

etc .. each up to 100 lines long

You are probably going to have to join the files up first:

$ cat transaction.txt.1* > joined.txt

And then split into N (5 in this example) pieces (here we avoid splitting lines with the 1/ format to the -n option):

$ split -n 1/5 -d -a 3 joined.txt transaction.txt.
$ ls transaction.txt.0*
transaction.txt.000  transaction.txt.001  transaction.txt.002  transaction.txt.003  transaction.txt.004

Thanks Chubler...

I used following command to get the nearest result.

 split -l $(( $( wc -l < file_name ) / 16 + 1 )) -d -a 2 filename expectedfilename