Do you mean to insert a column from file1 as any column in file2? Assuming that the two files have the same number of columns and there are no blank elements, you can try something like
Code:
{ getline line < ifile
split(line,array)
for (i = 1; i <= ocol - 1; i++)
printf("%s ", $i)
printf("%s ", array[icol])
for (i = ocol; i <= NF; i++)
printf("%s ", $i)
printf("\n")
}
where
icol is the column to read from file1 (that is the second field to extract, in your example),
ocol is the column to insert in file2 and
ifile is the input file (file1). If you put the above code in a file, e.g script.awk, you can launch it as
Code:
gawk -v icol=2 -v ocol=2 -v ifile=file1 -f script.awk file2
You can play with this code adding some controls. For details about the usage of the getline statement in gawk, the reference is the Gawk: Effective AWK Programming guide, section 3.8.4. Bye