• [^] # Re: Bon autant vous montrez le complet ça vous aidera peut etre

    Posté par . En réponse au message Utilisation de awk pour la jointure de 2 fichiers. Évalué à 1.

    #!/bin/bash
    ########################################################################
    ########################################################################
    #Recuperation des addresse mac dans un fichier au format decimal et hexa
    #creation du fichier mac1016.dat contenant la relation mac hex / mac deci
    snmpwalk -v 2c -c public -OX xxx.xxx.xxx.xxx 1.3.6.1.2.1.17.4.3.1.1 | \
    cut -c29- | \
    awk -F " " '{ print 1,ドル4ドル":"5ドル":"6ドル":"7ドル":"8ドル":"9ドル }' | \
    sort > /scriptsOID/mac1016.dat
    #recuperation du portbridge et creation de bridge.dat
    snmpwalk -v 2c -c public -Of xxx.xxx.xxx.xxx .1.3.6.1.2.1.17.4.3.1.2 |\
    cut -c44- | \
    awk -F " " '{ print 1,ドル4ドル }' | \
    sort > /scriptsOID/bridge.dat
    #recuperation du portID et créion du fichier portid.dat
    snmpwalk -v 2c -c public -Of xxx.xxx.xxx.xxx .1.3.6.1.2.1.17.1.4.1.2 | \
    cut -c45- | \
    awk -F " " '{ print 4,ドル1ドル }' | \
    sort > /scriptsOID/portid.dat
    #recuperation du port et créion de port.dat
    snmpwalk -v 2c -c public -Of xxx.xxx.xxx.xxx .1.3.6.1.2.1.31.1.1.1.1 | \
    cut -c78- | \
    awk -F " " '{ print 1,ドル4ドル }' > /scriptsOID/port.dat
    #jointure entre les fichier .dat pour former un fichier unique servant de base de donnee
     #jointure de mac1016.dat et port bridge.dat pour former ma .sortc
     join -1 1 -2 1 ./mac1016.dat <(fgrep -f <(cut -d ' ' -f 1 ./mac1016.dat) bridge.dat) | \
     awk -F " " '{ if (3ドル<49) print 3,ドル 2ドル} ' | \
     sort > mac.sort
     #jointure de portid.dat et port.dat pour former portname.sort
     join -1 1 -2 1 ./portid.dat <(fgrep -f <(cut -d ' ' -f 1 ./portid.dat) port.dat) | \
     cut -d ' ' -f 2,3 | \
     awk -F " " '{ if (1ドル<49) print 1,ドル 2ドル} ' >./portname.sort
     #jointure de mac16bridge.dat et portname.dat pour former le fichier final BD.dat
     join -1 1 -2 1 ./mac.sort <(fgrep -f <(cut -d ' ' -f 1 ./mac.sort) portname.sort)> BD.dat
    
    

    Ma dernière jointure est toujours impossible , je cherche activement une solution.

    Voici le contenu des 2 fichiers a jointer au cas ou vous auriez une idée.

    mac.sort
    1 00:B0:D0:22:46:16
    2 00:25:B3:0E:64:FE
    26 00:03:BA:12:53:6A
    27 00:03:BA:44:91:58
    28 08:00:20:CE:DB:06
    40 00:60:08:2D:27:28
    
    

    et le deuxieme :

    portname.sort
    1 Ethernet1/0/1
    2 Ethernet1/0/2
    3 Ethernet1/0/3
    4 Ethernet1/0/4
    5 Ethernet1/0/5
    6 Ethernet1/0/6
    7 Ethernet1/0/7
    8 Ethernet1/0/8
    9 Ethernet1/0/9
    10 Ethernet1/0/10
    11 Ethernet1/0/11
    12 Ethernet1/0/12
    13 Ethernet1/0/13
    14 Ethernet1/0/14
    15 Ethernet1/0/15
    16 Ethernet1/0/16
    17 Ethernet1/0/17
    18 Ethernet1/0/18
    19 Ethernet1/0/19
    20 Ethernet1/0/20
    21 Ethernet1/0/21
    22 Ethernet1/0/22
    23 Ethernet1/0/23
    24 Ethernet1/0/24
    25 Ethernet1/0/25
    26 Ethernet1/0/26
    27 Ethernet1/0/27
    28 Ethernet1/0/28
    29 Ethernet1/0/29
    30 Ethernet1/0/30
    31 Ethernet1/0/31
    32 Ethernet1/0/32
    33 Ethernet1/0/33
    34 Ethernet1/0/34
    35 Ethernet1/0/35
    36 Ethernet1/0/36
    37 Ethernet1/0/37
    38 Ethernet1/0/38
    39 Ethernet1/0/39
    40 Ethernet1/0/40
    41 Ethernet1/0/41
    42 Ethernet1/0/42
    43 Ethernet1/0/43
    44 Ethernet1/0/44
    45 Ethernet1/0/45
    46 Ethernet1/0/46
    
    

    Merci d'avance