脚本内容
vlookup.sh
#!/bin/bash
awk 'NR==FNR{a[$1]=$0;next}NR>FNR{if($1 in a)print $0" "a[$1]}' $1 $2 >vlookup_result
[root@localhost/home/]#cat aa
1 a e
2 b f
3 c g
4 d h
5 i j
[root@localhost/home/]#cat bb
4
3
2
1
[root@localhost/home/]#./vlookup.sh aa bb
[root@localhost/home/]#cat vlookup_result
4 4 d h
3 3 c g
2 2 b f
1 1 a e