- 论坛徽章:
- 0
|
回复 6# csccyab
[root@sftp02 tmp]# cat a.txt
Common App
19933400 FY
19933400 FY
[root@sftp02 tmp]# cat b.txt
Common App
19933400 FY
20478740 FY
17580349 FY
20224366 FY
20349770 FY
21604135 FY
21642087 FY
21763159 FY
21819993 FY
[root@sftp02 tmp]# awk 'FILENAME==ARGV[1]{ b[++i]=$0; count++} FILENAME==ARGV[2]{if (FNR==1){print $0,b[1]} else {if (!a[$1]){ for (i=2;i<=count;i++){print $0,b}}a[$1]=$1}}' b.txt a.txt
Common App Common App
awk: cmd. line:1: (FILENAME=a.txt FNR=2) fatal: attempt to use array `b' in a scalar context
[root@sftp02 tmp]#
|
|