hello
I have this bash script to match 2 tables using one column.
function awkcrossmatch() {
if [ $# = 3 ]
then
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
elif [ $# = 4 ]
then
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 > $4
fi
}
I would like now to match 2 tables using 3 columns. For example to match these tables
table1:
col1, col2, col3, col4 ... coln
12,233,44445 ... 2334
12,233,44445 ... 2334
12,233,44445 ... 2334
table2:
col1, col2, col3, col4 ... coln
12,233,44445 ... 2334
12,233,44445 ... 2334
12,233,44445 ... 2334
using col2, col3 and col5. Could someone help me on this?
thanks
p
I have this bash script to match 2 tables using one column.
function awkcrossmatch() {
if [ $# = 3 ]
then
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
elif [ $# = 4 ]
then
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 > $4
fi
}
I would like now to match 2 tables using 3 columns. For example to match these tables
table1:
col1, col2, col3, col4 ... coln
12,233,44445 ... 2334
12,233,44445 ... 2334
12,233,44445 ... 2334
table2:
col1, col2, col3, col4 ... coln
12,233,44445 ... 2334
12,233,44445 ... 2334
12,233,44445 ... 2334
using col2, col3 and col5. Could someone help me on this?
thanks
p