There's a bash script I've been working on and within this script at some point, I have been trying to figure out how to process two CSV files at once using awk, which will be used to produce several output files. Shortly, there's a main file which keeps the content to be dispatched to some other output files whose names and the number of records they need to be hold, will be derived from another file. First n records will go to first output file and consequent n+1 to n+k to second one and so on.
To be more clear here's an example of how the main record file might look:
x11,x21
x12,x22
x13,x23
x14,x24
x15,x25
x16,x26
x17,x27
x18,x28
x19,x29
and how the other file might look like:
out_file_name_1,2
out_file_name_2,3
out_file_name_3,4
Then the first output file named as out_file_name_1 should look like:
x11,x21
x12,x22
Then the second output file named as out_file_name_2 should look like:
x13,x23
x14,x24
x15,x25
And the last one should look like:
x16,x26
x17,x27
x18,x28
x19,x29
Hopefully it is clear enough.