001、
[root@pc1 test01]# cat a.txt A:10 B:5 C:12 [root@pc1 test01]# cat b.txt 100 A 50 B 88 K 99 Y 42 C [root@pc1 test01]# awk '{if(NR == FNR) {ay[$1] = $2} else {print $2, $1, ay[$2]}}' FS=":" a.txt FS=" " b.txt A 100 10 ## 一般输出 B 50 5 K 88 Y 99 C 42 12 [root@pc1 test01]# awk '{if(NR == FNR) {ay[$1] = $2} else if($2 in ay) {print $2, $1, ay[$2]}}' FS=":" a.txt FS=" " b.txt A 100 10 ## 精确输出 B 50 5 C 42 12
。
标签:FS,test01,pc1,按列,awk,linux,ay,txt From: https://www.cnblogs.com/liujiaxin2018/p/17687377.html