BEGIN{ infreq=ARGV[2]; ARGC--; n=1; while((getline < infreq)>0) line[$1]=n++; } { for (i = 1; i <= NF; i ++) printf("%s ", line[$i]); printf("\n"); }