# Write out table2 in the same order as table1 ################################################ BEGIN { # Order of table1: cmd = "fcat ./table1.dat | acut -c1-10" ; while ((cmd | getline)) { n++; name[n] = $0 } close(cmd) # Contents of table2: cmd = "fcat table2.dat"; while ((cmd | getline)) { rec[substr($0,1,10)] = substr($0,11) } close(cmd) for (i=1; i<=n; i++) { star = name[i]; print star rec[star] } } { next }