We have two files with results of two commands of cisco:
one file; showintstatus, have the following format:
Gi2/6 servidorlij connected 176 full 1000 10/100/1000BaseT
second file; showmacaddrestable, have the following format:
* 162 0021.9b8d.073e dynamic Yes 0 Gi4/39
The important fields are $2,$3,$7.
And when join the two files have some problems because some ports have several mac address and the result is:
Gi2/11 serverusa connected 176 full 1000 10/100/1000BaseT 176 0019b9e365d6 Gi2/11 176 001d09f0a40d Gi2/11 176 002497f8e8cb Gi2/11 176 0001d7711f05 Gi2/11
I'm looking for the next result when in the port have more than one mac address:
Gi2/11 serverusa connected 176 full 1000 10/100/1000BaseT 176 0019b9e365d6 Gi2/11
Gi2/11 serverusa connected 176 full 1000 10/100/1000BaseT 176 001d09f0a40d Gi2/11
Gi2/11 serverusa connected 176 full 1000 10/100/1000BaseT 176 002497f8e8cb Gi2/11
Gi2/11 serverusa connected 176 full 1000 10/100/1000BaseT 176 0001d7711f05 Gi2/11
the script that use:
#!/bin/bash
for i in $( more ports ); do
cat showintstatus.2 showmacaddresstable.1 | grep -w $i | awk -vORS=' ' 1
echo -e "\n"
done
the file ports contain a list of ports with the format:
Gi2/13
Gi2/14
Gi2/15
Gi2/16
Gi2/17
I'm newbie in this area and will be appreciate your help