split file into multiple files

Hi,

I have a file of the following syntax that has around 120K records that are tab separated.

input.txt

abc	def	klm	20	76	.	+	.	klm_mango unix_00000001;
abc	def	klm	83	84	.	+	.	klm_mango unix_0000103;
abc	def	klm	415	439	.	+	.	klm_mango unix_00001043;

I am looking for an awk oneliner that could split this input.txt file into multiple files of 5K records in each file with the name input_1.txt, input_2.txt ....

All helps are appreciated.

Read up on the split command, maybe that will work for you.

man split

I used the following command and it works fine for me

awk '{print >("input_" int((NR+4999)/5000))}' input.txt
1 Like