awk 多文件join

cat score.dat

id score rank
1 90 2
2 95 1

cat name.dat

id name
1 zhangsan
2 leesi

#if is name.dat;then create_map and continue; else print score.dat and decode id to name
awk 'NR==FNR { a[$1]=$2; next } { print $0, a[$1]}' name.dat score.dat 

id score rank name
1 90 2 zhangsan
2 95 1 leesi

你可能感兴趣的:(awk 多文件join)