Please put your code in "Code" tabs -- makes it much easier to read. Also, posting the errors you received can be very useful in diagnosing your problem
Try this:
Code:
awkcrossmatch () {
awk -v col="$1" '{v=FNR==1?"\n":col} NR==FNR
{a[v]=col; b[v]=$0; next}
v in a {print b[v],$0}' $2 $3
}
I think you were running afoul of
awk's quoting rules. Suggest reading the
gawk info page. (##gawk in Konqueror.)
What I have written above assumes you will supply the
column # w/ the leading '$' sign, as in your example.