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.
gary_w
April 3, 2012, 10:19am
2
Read up on the split command, maybe that will work for you.
man split
jacobs.smith:
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.
I used the following command and it works fine for me
awk '{print >("input_" int((NR+4999)/5000))}' input.txt
1 Like