- 论坛徽章:
- 2
|
回复 24# 鸟鸟不哥
是这个意思吗?- awk '
- BEGIN{S="NULL NULL NULL 0";
- while(getline line1 <"file1"){
- split(line1,s1," ");
- getline line2 <"file2";
- split(line2,s2," ");
- if(s2[2] == s1[2] && s2[3] == s1[3]){print line1 " " line2;}
- else{
- m=S " "line2;t=line2;
- while(getline line2 <"file2"){
- split(line2,s2," ");
- if(s2[2] == s1[2] && s2[3] == s1[3]){print line1 " " line2;print m;t=m="";break}
- else{
- m=m RS S" "line2;t=t RS line2
- # print t"#";
- }
- }
- if(m){
- print line1 " " S;
- for(i=1;i<=split(t,n,"\n");i++){
- split(n[i],s2," ");
- while(getline line1<"file1"){
- split(line1,s1," ");
- if(s2[2] == s1[2] && s2[3] == s1[3]){print line1 " " n[i];print x;x=y="";break}
- else{
- x=line1 " "S;y=line1;
- #print S " " line2
- }
- }
- if(y){
- print S" "n[i]
- for(j=1;j<=split(y,z,"\n");j++){
- split(z[i],s1," ");
- if(s2[2] == s1[2] && s2[3] == s1[3]){print z[j] " " n[i];break};
- }
- }
- }
- }
- }
- }
- }}'
复制代码 |
|