Comparação de colunas usando awk [duplicate]

0

Eu gostaria de comparar a primeira coluna do arquivo1 com a segunda coluna do arquivo2 e somente se eles corresponderem, ela deve exibir qualquer linha correspondente no arquivo2 somente como saída. As colunas são separadas por | .

file1 :

syfar03040k16.audc1.oraclecloud.com |
syfar03040m02.audc1.oraclecloud.com |
syfar03040m04.audc1.oraclecloud.com |
syfar03040n11.audc1.oraclecloud.com |
syfar03040n01.audc1.oraclecloud.com |
syfar03040n02.audc1.oraclecloud.com |
syfar03040n03.audc1.oraclecloud.com |
syfar03040n05.audc1.oraclecloud.com |
syfar03040n07.audc1.oraclecloud.com |
syfar03040o11.audc1.oraclecloud.com |
syfar03040o01.audc1.oraclecloud.com |
syfar03040o02.audc1.oraclecloud.com |
syfar03040o03.audc1.oraclecloud.com |
syfar03040o13.audc1.oraclecloud.com |
syfar03040o05.audc1.oraclecloud.com |
syfar03040o04.audc1.oraclecloud.com |
syfar03040o16.audc1.oraclecloud.com |

file2 :

   | LDAP                 | syfar03040o11.audc1.oraclecloud.com               |
   | OIM                  | syfar03040o01.audc1.oraclecloud.com               |
   | AUTHOHS              | syfar03040o02.audc1.oraclecloud.com               |
   | APPOHS               | syfar03040o03.audc1.oraclecloud.com               |
   | BI                   | syfar03040o04.audc1.oraclecloud.com               |
   | ADMIN                | syfar03040o05.audc1.oraclecloud.com               |
   | PRIMARY              | syfar03040o06.audc1.oraclecloud.com               |
   | SECONDARY            | syfar03040o07.audc1.oraclecloud.com               |
   | APPOHS_HA1           | syfar03040o13.audc1.oraclecloud.com               |
   | PRIMARY_HA1          | syfar03040o16.audc1.oraclecloud.com               |
   | SECONDARY_HA1        | syfar03040o17.audc1.oraclecloud.com               |
   | OSN                  | syfar03040o09.audc1.oraclecloud.com               |

File3 :

   | LDAP                 | syfar03040o11.audc1.oraclecloud.com               |
   | OIM                  | syfar03040o01.audc1.oraclecloud.com               |
   | AUTHOHS              | syfar03040o02.audc1.oraclecloud.com               |
   | APPOHS               | syfar03040o03.audc1.oraclecloud.com               |
   | BI                   | syfar03040o04.audc1.oraclecloud.com               |
   | ADMIN                | syfar03040o05.audc1.oraclecloud.com               |
   | APPOHS_HA1           | syfar03040o13.audc1.oraclecloud.com               |
   | PRIMARY_HA1          | syfar03040o16.audc1.oraclecloud.com               |
    
por neha dhawan 04.04.2016 / 20:20

1 resposta

1
awk '
    NR == FNR {
        file1[$1] = 1;
        next;
    }
    $4 in file1 {
        print $0;
    }
' file1 file2
    
por 04.04.2016 / 21:01