Q:

Using awk on multiple input files

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.

A:

I wouldn't use Awk for this.
while IFS=, read -u 3 filename lines; do
    head -n "$lines" >"$filename"
done 3<other.csv <main.csv

The read -u to read from a particular file descriptor is not completely portable, I believe, but your question is tagged bash so I am assuming that is not a problem here.
Demo: http://ideone.com/6FisHT
If you end up with empty files after the first, maybe try to replace the inner loop with additional read statements.
while IFS=, read -u 3 filename lines; do
    for i in $(seq 1 "$lines"); do
        read -r line
        echo "$line"
    done >"$filename"
done 3<other.csv <main.csv

