hey guys, i just joined. Looks like cool community, thanks in advance.
I have an AWK script, "awk.prog", that I launch with a text file that looks like this:
awk -f awk.prog -v inFile1=file1.txt -v inFile2=file2.txt -v inFile3=file3.txt .
.
.
...etc...
and then in the AWK script I have this:
I would much prefer to do it somehow like this:
awk -f awk.prog -v inFile[1]=file1.txt -v inFile[2]=file2.txt -v inFile[3]=file3.txt ...etc....
and have the AWK script like this:
Is there some way to do this? ...to pass the "file*.txt" filenames to the AWK program thru an array as I've done above? In actuality I am passing 50+ variables to my AWK program using the -v parameter, including ~25 input filenames. Thanks for any help.
I have an AWK script, "awk.prog", that I launch with a text file that looks like this:
awk -f awk.prog -v inFile1=file1.txt -v inFile2=file2.txt -v inFile3=file3.txt .
.
.
...etc...
and then in the AWK script I have this:
Code:
readFile(inFile1);
readFile(inFile2);
readFile(inFile3);
function readFile(file)
{
while( (getline < file) > 0)
...
}
I would much prefer to do it somehow like this:
awk -f awk.prog -v inFile[1]=file1.txt -v inFile[2]=file2.txt -v inFile[3]=file3.txt ...etc....
and have the AWK script like this:
Code:
for(a=0; a<number_of_inFiles; a++)
{
readFile(inFile[a]);
}
Is there some way to do this? ...to pass the "file*.txt" filenames to the AWK program thru an array as I've done above? In actuality I am passing 50+ variables to my AWK program using the -v parameter, including ~25 input filenames. Thanks for any help.