shell 匹配两个文件第一列相同的行
两个文件全量表和非全量表
[root@ls-mqgyre8l ~]# cat quanliang.txt
计算节点 搜索码 带外ip
compute01 hyper-001 10.116.21.11
compute02 hyper-002 10.116.21.12
compute03 hyper-003 10.116.21.13
compute04 hyper-004 10.116.21.14
compute05 hyper-005 10.116.21.15
compute06 hyper-006 10.116.21.16
compute07 hyper-007 10.116.21.17
compute08 hyper-008 10.116.21.18
compute09 hyper-009 10.116.21.19
compute10 hyper-010 10.116.21.20
compute11 hyper-011 10.116.21.21
compute12 hyper-012 10.116.21.22
compute13 hyper-013 10.116.21.23
compute14 hyper-014 10.116.21.24
compute15 hyper-015 10.116.21.25
[root@ls-mqgyre8l ~]#
[root@ls-mqgyre8l ~]# cat tongji.txt
计算节点
compute01
compute03
compute04
compute01
compute03
compute04
compute09
compute07
compute10
compute11
根据quanliang.txt把tongji.txt补齐
[root@ls-mqgyre8l ~]# awk 'NR==FNR{a[$1]=$0; next} $1 in a{print a[$1], $0}' quanliang.txt tongji.txt
计算节点 搜索码 带外ip 计算节点
compute01 hyper-001 10.116.21.11 compute01
compute03 hyper-003 10.116.21.13 compute03
compute04 hyper-004 10.116.21.14 compute04
compute01 hyper-001 10.116.21.11 compute01
compute03 hyper-003 10.116.21.13 compute03
compute04 hyper-004 10.116.21.14 compute04
compute09 hyper-009 10.116.21.19 compute09
compute07 hyper-007 10.116.21.17 compute07
compute10 hyper-010 10.116.21.20 compute10
compute11 hyper-011 10.116.21.21 compute11