help on bash
Hi,
I have this simple awk script that cross-match 2 tables/files using for example their 3th columns awk '{v=FNR==1?"\n":$3} NR==FNR {a[v]=$3; b[v]=$0; next} v in a {print b[v],$0}' fileName1 fileName2 I would like to put this function into .bashrc function awkcrossmatch() { tmp=$1 awk '{v=FNR==1?"\n":$tmp} NR==FNR {a[v]=$tmp; b[v]=$0; next} v in a {print b[v],$0}' $2 $3 } Why this calling sequence doesnot work? awkcrossmatch '$3' fileName1 fileName2 How to write this properly? Thanks oliver |
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 () { What I have written above assumes you will supply the column # w/ the leading '$' sign, as in your example. |
All times are GMT -5. The time now is 12:19 AM. |